Removing Items from 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.

The scavenging and expiration processes automatically remove items from the cache according to the priorities and expiration policies of the items. You can also remove specific items from the cache. For example, in a retail application, some data may no longer be applicable, depending on selections the customer makes.

Typical Goals

In this scenario, you want to remove specific items from the cache.

Solution

Use the Remove method provided by the CacheManager class. The Remove method removes a specific item from the cache.

QuickStart

For an extended example of how to use the Remove method, see the QuickStart walkthrough, Walkthrough: Removing Items From the Cache.

Using the Remove Method

The following code shows how to use the Remove method.

public void Remove(CacheManager cache, string key)
{
  cache.Remove(key);
}
Public Sub Remove(ByVal cache As CacheManager, ByVal key As String)
  cache.Remove(key)
End Sub
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.