NCache 4.6 - Online Documentation

Querying Data in NCache

 
NCache provides the ability to query indexed cache data through its own indexing mechanism. Indexing for searchable objects and their attributes need to be configured first as explained in Configuring Query Indexes in Administrator's Guide.
 
Using API for Querying
 
Previously, NCache had the APIs Search and SearchEntries for returning the query result, but they have been marked obsolete now. Preferably use ExecuteReader for your application.
 
The following API is available for using NCache query feature:
 
      public ICacheReader ExecuteReader(string query, IDictionary values);
      public ICacheReader ExecuteReader(string query, IDictionary values, bool getData);
      public ICacheReader ExecuteReader(string query, IDictionary values, bool getData, int chunkSize);
public int ExecuteNonQuery(string query, IDictionary values);
 
[Deprecated]
public ICollection Search(string query, IDictionary values)
 
Reason: Returned the list of keys whose data fulfilled the result criteria. For large scale data, the collection tends to be large, putting a pressure on network cost.
 
public IDictionary SearchEntries(string query, IDictionary values)
 
Reason: Returned the list of keys with data whose data fulfilled the result criteria. Reason is same as above, with the size of dictionary tending to be exponentially greater than a keys-only collection.
 
Methods
 
Name
Return Type
Description
ExecuteReader
ICacheReader
Returns list of key-value pairs in result set which fulfills the query criteria. This key value pair has cache key and its respective value.
You can still get the keys-only result like Search through varying overloads.   
ExecuteNonQuery
int
Used in queries containing Delete operations. Returns number of affected rows after query is executed.
Search
ICollection
Only returns list of keys in result set which fulfill the query criteria.
SearchEntries
IDictionary
Returns list of key-value pairs in result set which fulfills the query criteria.
 
Parameters
 
    Name
    Type
    Description
query
string
Query string but instead of values '?' will be specified by user, e.g., "SELECT Product WHERE this.ProductID == ?"
   
values
IDictionary
Key-value pairs of attribute-names and their values on which your search criteria is based on.
 
    Hashtable values = new Hashtable();
  values.Add("ProductID", 1);
   
getData
bool
Flag to indicate whether you want to get the resulting values of the query or not.
chunkSize
int
Size of the chunk which ExecuteReader will send to the user after processing on the server.
 
 
In this section:
 
Explains how indexed items can be added and updated in the cache.
 
Explains how items can be searched to return keys.
 
Explains how items can be searched to return keys along with items themselves.
 
Provides code samples for using query operators.
 
 
See Also