Remove Existing Data Structure from Cache
This feature is only available in the NCache Enterprise.
You can remove an existing data structure from the cache using the
Remove method of
DataTypeManager or through the
cache.Remove method as well. If the key does not exist, nothing is returned.
Remove Data Structures from Cache
One quick way to verify whether the data structure has been removed is to use either properties of the
Containsverifies if the specified key exists in the cache.
Countreturns the number of items present in the cache.
The following example assumes the key exists against a data structure in the cache. The data structure is then removed from the cache using this key.
// Precondition: Cache is connected // Key exists in cache string key = "ProductIDList"; // Remove List from Cache cache.DataTypeManager.Remove(key);
To ensure the operation is fail-safe, it is recommended to handle any potential exceptions within your application, as explained in Handling Failures.
NCache provides a sample application for removing data structures from cache on GitHub.