Retrieving Data Group Items from Cache
To utilize the APIs, include the following namespace in your application:
Alachisoft.NCache.Web.Caching.
Retrieving Keys of a Particular Group
To return list of keys that belongs to a specified group and sub-group, you can use the GetGroupKeys method. This method returns a list of keys.
string groupName = "Product";
string subGroupName = "Beverages";
try
{
ArrayList keys = cache.GetGroupKeys(groupName, subGroupName);
foreach (object obj in keys){
//do something
}
}
catch (Exception ex)
{
//handle exception
}
Retrieving Keys and Values of a Particular Group
To return the dictionary of keys and values that belong to a specified group and sub-group, the GetGroupData method can be used. This method returns a dictionary of keys and values.
string groupName = "Product";
string subGroupName = "Beverages";
try
{
ArrayList keys = cache.GetGroupKeys(groupName, subGroupName) as IDictionary;
if (data.Count > 0)
{
IDictionaryEnumerator result = data.GetEnumerator();
while (result.MoveNext())
{
string key = (string)result.Key;
Product val = (Product)result.Value;
//do something
}
}
}
catch (Exception ex)
{
// handle exception
}