MemoryCache.Remove 方法

定义

从缓存中移除指定的项。

重载

Remove(String, String)

从缓存中移除某个缓存项。

Remove(String, CacheEntryRemovedReason, String)

使用原因从缓存中删除缓存项。

Remove(String, String)

Source:
MemoryCache.cs
Source:
MemoryCache.cs
Source:
MemoryCache.cs

从缓存中移除某个缓存项。

public override object Remove (string key, string regionName = default);
override this.Remove : string * string -> obj
Public Overrides Function Remove (key As String, Optional regionName As String = Nothing) As Object

参数

key
String

要移除的缓存项的唯一标识符。

regionName
String

缓存中的一个添加了缓存项的命名区域。 不要为该参数传递值。 默认情况下,此参数为null,因为 MemoryCache 类未实现区域。

返回

如果在缓存中找到该项,则为已移除的缓存项;否则为 null

例外

regionName 不是 null

keynull

注解

如果 由 指定的 key 条目存在于缓存中,则删除该项会触发任何关联的更改监视器。 如果已删除的项与 CacheItemUpdateCallback 对象或 CacheItemRemovedCallback 对象相关联,则传递给回调的原因为 Removed

适用于

Remove(String, CacheEntryRemovedReason, String)

Source:
MemoryCache.cs
Source:
MemoryCache.cs
Source:
MemoryCache.cs

使用原因从缓存中删除缓存项。

public object Remove (string key, System.Runtime.Caching.CacheEntryRemovedReason reason, string regionName = default);
override this.Remove : string * System.Runtime.Caching.CacheEntryRemovedReason * string -> obj
Public Function Remove (key As String, reason As CacheEntryRemovedReason, Optional regionName As String = Nothing) As Object

参数

key
String

要移除的缓存项的唯一标识符。

reason
CacheEntryRemovedReason

删除项的原因。

regionName
String

缓存中的一个添加了缓存项的命名区域。 不要为该参数传递值。 默认情况下,此参数为null,因为 MemoryCache 类未实现区域。

返回

如果在缓存中找到该项,则为已移除的缓存项;否则为 null

适用于