ASP.NET Applications > ASP.NET Optimization > ASP.NET Caching Features > Caching Application Data > Deleting Items from the Cache
ASP.NET Web Applications ASP .NET Caching Features Caching Application Data
There are several reasons for an item to be removed from an application’s Cache. You can set expiration policies that determine the total amount of time the item remains in the cache ( absolute expiration ), or the amount of time that must pass since the last time the item was accessed ( sliding expiration ). You can also specify files, directories, or keys that the item is dependent on. The item is removed from the cache when those dependencies change.
The server itself can remove an item from the cache when it needs to free memory ( scavenging ). You have control over the priorities of cached items when this occurs. In addition, you can explicitly remove items from the cache by using the Cache.Remove method.
- The Remove method has one parameter that allows you to specify the key of the item you want to remove. For example, the following code removes an item assigned the
myData key.
Cache.Remove ( "myData" );
Cache.Remove ( "myData" ) |
|
C# |
VB |
Adding Items to the Cache Retrieving Values of Cached Items| Notifying Applications When an Item is Deleted from the Cache
|