Bewerken

Share via


CacheItemRemovedReason Enum

Definition

Specifies the reason an item was removed from the Cache.

public enum class CacheItemRemovedReason
public enum CacheItemRemovedReason
type CacheItemRemovedReason = 
Public Enum CacheItemRemovedReason
Inheritance
CacheItemRemovedReason

Fields

Name Value Description
Removed 1

The item is removed from the cache by a Remove(String) method call or by an Insert(String, Object) method call that specified the same key.

Expired 2

The item is removed from the cache because it expired.

Underused 3

The item is removed from the cache because the system removed it to free memory.

DependencyChanged 4

The item is removed from the cache because the cache dependency associated with it changed.

Examples

The following code example demonstrates a shared Boolean property, itemRemoved, a shared CacheItemRemovedReason enumeration object, reason, and a CacheItemRemovedCallback delegate, onRemove. The latter can be included in an Insert or Add method call. It also defines a method, RemovedCallback, with a signature that matches the CacheItemRemovedCallback delegate. When the RemovedCallback method is called, it changes the itemRemoved property value to true and assigns the reason property value to the reason provided by the CacheItemRemovedReason enumeration.

static bool itemRemoved = false;
static CacheItemRemovedReason reason;
CacheItemRemovedCallback onRemove = null;

public void RemovedCallback(String k, Object v, CacheItemRemovedReason r){
  itemRemoved = true;
  reason = r;
}
Shared itemRemoved As boolean = false
Shared reason As CacheItemRemovedReason
Dim onRemove As CacheItemRemovedCallback

Public Sub RemovedCallback(k As String, v As Object, r As CacheItemRemovedReason)
  itemRemoved = true
  reason = r
End Sub

Remarks

This enumeration is used by the CacheItemRemovedCallback delegate to notify your ASP.NET applications when and why an object was removed from the Cache.

Applies to

See also