Flushing lets you manage cached items to make sure that storage, memory, and other resources are used efficiently. Flushing removes all items in the cache, including those that have not yet expired. For example, in a retail application, cached data may no longer be valid because of selections made by the customer or because the customer has logged off.
In this scenario, you want to remove all items from cache.
Use the Flush method provided by the CacheManager class. The Flush method removes all items from the cache. If an error occurs, the cache does not change.
For an extended example of how to use the Flush method, see the QuickStart walkthrough, Walkthrough: Flushing the Cache.
The following code shows how to use the Flush method. Add the code to the method that responds to the request to flush the cache.
ICacheManager productsCache = CacheFactory.GetCacheManager();
// Operations on the cache
productsCache.Flush();
Dim productsCache As ICacheManager = CacheFactory.GetCacheManager()
' Operations on the cache
productsCache.Flush()