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枚举CacheItemRemovedCallback对象reason、和委托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. CacheItemRemovedReason reason true itemRemoved调用方法时, 它会将属性值更改为, 并将属性值分配给枚举提供的原因。 RemovedCallbackWhen 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委托用来在与从中移除对象时通知你的CacheASP.NET 应用程序。This enumeration is used by the CacheItemRemovedCallback delegate to notify your ASP.NET applications when and why an object was removed from the Cache.

适用于

另请参阅