NCache 4.6 - Online Documentation

Querying Cached Items With Respect To Tags

The following examples demonstrate how to query items from NCache, with respect to the tags.
In the following code example, please specify the fully qualified name of your custom class instead of 'Product' in the query string.
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
        Hashtable queryValue = new Hashtable();
        string query = "SELECT Product WHERE this.$Tag$=? AND this.$Tag$=?";
        //Add items to cache containing tags in ArrayList if multiple tags value is required.
        ArrayList queryTagList = new ArrayList();
        // Add tag list to Hashtable for query searching values.
        queryValue.Add("$Tag$", queryTagList);
            ICacheReader queryResult = cache.ExecuteReader(query, queryValue, true);
            // queryResult contains all keys related to both tags.
            if (queryResult.FieldCount > 0)
                while (queryResult.Read())
                    //perform operations
              //no record exists
        catch (OperationFailedException ex)
            // handle exception
See Also