NCache 4.6 - Online Documentation


Most of the applications use cache for storing key-value pair type of data. Every data item can be retrieved through keys like primary keys are used to find data in any relational database. This approach seems good when it is known that which key is associated with what kind of data but in large and complex applications, items cannot be retrieved through keys only. There might be a need to search relative data for any specific attribute value because a lot of live data is stored in the cache. A very basic example can be of a web e-commerce application where there might be a need for fetching all products related to specific category etc. In such a case, category based keys cannot be specified for all the products and hence keys lists cannot be used for retrieval.
For searching purpose, NCache provides a powerful searching mechanism where cache keys/data can be fetched using SQL like query syntax. NCache provides with OQL (Object Query Language) which is the subset of SQL. OQL facilitates searching the cache against  criteria on which data is required. For the e-commerce web application, if all the products related to a particular category are to be retrieved, then a sample query in NQL would be something like follows:
       Sample query: "SELECT Product WHERE this.Category = ?"
By specifying a particular category in this query,  all product keys and cached items that have the specified category can be searched.
NCache allows searching and deleting result set according to a query criteria. It means that cache can be updated through queries at runtime when needed. NCache requires all searchable attributes to be indexed before using those indexes. These settings are not hot applicable so they should be defined before cache start. See Indexing in NCache for details on indexing.
See Also