Partilhar via


Removing Items from the Cache

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.

Using the Remove Method

The following code shows how to use the Remove method.

public void Remove(ICacheManager cache, string key)
{
  cache.Remove(key);
}
'Usage
Public Sub Remove(ByVal cache As ICacheManager, ByVal key As String)
  cache.Remove(key)
End Sub