CacheItemRemovedReason CacheItemRemovedReason CacheItemRemovedReason CacheItemRemovedReason Enum

定义

指定从 Cache 对象移除项的原因。Specifies the reason an item was removed from the Cache.

public enum class CacheItemRemovedReason
public enum CacheItemRemovedReason
type CacheItemRemovedReason = 
Public Enum CacheItemRemovedReason
继承
CacheItemRemovedReasonCacheItemRemovedReasonCacheItemRemovedReasonCacheItemRemovedReason

字段

DependencyChanged DependencyChanged DependencyChanged DependencyChanged 4

从缓存移除该项的原因是与之关联的缓存依赖项已更改。The item is removed from the cache because the cache dependency associated with it changed.

Expired Expired Expired Expired 2

从缓存移除该项的原因是它已过期。The item is removed from the cache because it expired.

Removed Removed Removed Removed 1

该项是通过指定相同键的 Remove(String) 方法调用或 Insert(String, Object) 方法调用从缓存中移除的。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.

Underused Underused Underused Underused 3

之所以从缓存中移除该项,是因为系统要通过移除该项来释放内存。The item is removed from the cache because the system removed it to free memory.

示例

下面的代码示例演示了一个共享的布尔值属性, itemRemoved,在不共享CacheItemRemovedReason枚举对象reason,和一个CacheItemRemovedCallback委托, onRemoveThe following code example demonstrates a shared Boolean property, itemRemoved, a shared CacheItemRemovedReason enumeration object, reason, and a CacheItemRemovedCallback delegate, onRemove. 后者可以包含在InsertAdd方法调用。The latter can be included in an Insert or Add method call. 它还定义了一种方法, RemovedCallback,具有匹配签名CacheItemRemovedCallback委托。It also defines a method, RemovedCallback, with a signature that matches the CacheItemRemovedCallback delegate. RemovedCallback方法调用时,它会更改itemRemoved属性值设置为true,并将分配reason属性值设置为提供的原因CacheItemRemovedReason枚举。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

注解

此枚举由CacheItemRemovedCallback委托以通知 ASP.NET 应用程序何时和为什么要从已删除对象CacheThis enumeration is used by the CacheItemRemovedCallback delegate to notify your ASP.NET applications when and why an object was removed from the Cache.

适用于

另请参阅