Remove Cache Data with Group
Note
This feature is only available in NCache Enterprise.
NCache allows the user to remove the items with the data groups. It also allows the user to remove the data group with CacheItem
.
To remove cache items that belong to a specific group, the RemoveGroupData
method can be used. This method removes all the cache items mapped under the group passed to this API.
Prerequisites
- To learn about the standard prerequisites required to work with all NCache client-side features please refer to the given page on Client Side API Prerequisites.
- For API details refer to: ICache, RemoveGroupData, SearchService.
Important
- Passing empty strings for the group will return an empty result set.
- Passing null for the group will throw an
ArgumentNullException
. - Passing only the value of the group will remove all the cache items mapped under the group.
The following example removes the data under the group West Coast Customers.
// Preconditions: Cache is already connected
// A user wants to remove a customer from West Coast Region
// Items are previously added in the cache with the group 'West Coast Customers'
string groupName = "West Coast Customers";
// Cache items belonging to the group are removed from the cache
cache.SearchService.RemoveGroupData(groupName);
Note
To ensure the operation is fail-safe, it is recommended to handle any potential exceptions within your application, as explained in Handling Failures.
Additional Resources
NCache provides a sample application for Groups on GitHub.
See Also
Add/Update Cache Data with Groups
Retrieve Cache Data with Groups
Basic Operations for Caching Data
Tag Cache Data