Flushing the Cache
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The latest Enterprise Library information can be found at the Enterprise Library site. |
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.
Typical Goals
In this scenario, you want to remove all items from cache.
Solution
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.
QuickStart
For an extended example of how to use the Flush method, see the QuickStart walkthrough, Walkthrough: Flushing the Cache.
Using the Flush Method
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();
'Usage
Dim productsCache As ICacheManager = CacheFactory.GetCacheManager()
' Operations on the cache
productsCache.Flush()