Removing Items from the Cache

Microsoft Enterprise Library 5.0

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

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.


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.

C# Copy Code
public void Remove(ICacheManager cache, string key)
Visual Basic Copy Code
Public Sub Remove(ByVal cache As ICacheManager, ByVal key As String)
End Sub