Alachisoft NCache 4.1 - Online Documentation

Data Grouping

 
NOTE: This feature is not available in NCache Express and Professional edition.
 
Data grouping is a way to manage related objects in logical 'groups'. Every object being added in the cache can be tagged with a group identifier. Objects with same group identifier logically belong to the same group and can be identified by group identifier. The current version of NCache supports only two levels of grouping, a top level group and then its sub-groups.
For using Data Groups include the following namespace in your application:
 
using Alachisoft.NCache.Web.Caching;
using System.Collections;
 
 
Adding an item to a Data Group
 
The following code adds an item to data group 'sub-zero' inside group 'zero'.
 
Cache _cache = NCache.InitializeCache("mycache");
object item = "value" ;
_cache.Add("Customer:David:1001", item, "zero", "sub-zero");
 
Updating an item in a Data Group
 
The following code updates an item in data group 'sub-zero' inside group 'zero'.
 
Cache _cache = NCache.InitializeCache("mycache");
object item= "value1" ;
_cache.Insert("Customer:David:1001", item, "zero", "sub-zero");
 
Retrieving list of Data Group Keys
 
The following code retrieves list of items included in group 'zero'.
 
Cache _cache = NCache.InitializeCache("mycache");
ArrayList keys = _cache.GetGroupKeys("zero", null); sys.collection
foreach ( object obj in keys)
Console.WriteLine(obj);
 
Emptying a Data Group
 
The following code removes all items from data group 'sub-zero' inside group 'zero'.
 
Cache _cache = NCache.InitializeCache("mycache");
_cache.RemoveGroupData("zero", "sub-zero");
 
 
See Also
 
Copyright © 2005-2012 Alachisoft. All rights reserved.