Alachisoft NCache 4.1 - Online Documentation

Group/Subgroup

 
Data grouping is a way to manage related objects in logical 'groups'. Every object being added to 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 the group. The current version of NCache supports only two levels of grouping, a top level group and then its sub-groups. Include the following import statement in your project for using data groups:
 
import com.alachisoft.ncache.web.caching.*;
 
For 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("Cache");
Object value = "Can contain any Type";
_cache.add("Customer:David:1001", value, "my-group", "my-subGroup");
 
For 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("Cache");
Object value = "Can contain any Type";
_cache.insert("Customer:David:1001", value, "my-group", "my-subGroup");
 
For Retrieving list of Data Group Keys
 
The following code retrieves list of items included in group 'zero'.
 
Cache _cache = NCache.initializeCache("Cache");
Collection keys = _cache.getGroupKeys("my-group", "my-subGroup");
for(Object var : keys.toArray() )
{
System.out.print(var);
}
 
For Emptying a Data Group
 
The following code removes all items from data group 'sub-zero' inside group 'zero'.
 
Cache _cache = NCache.initializeCache("Cache");
_cache.removeGroupData("my-group", "my-subGroup");
 
 
 
See Also
 
Copyright © 2005-2012 Alachisoft. All rights reserved.