MemoryCache.Remove 方法

定義

從快取中移除指定的項目。

多載

名稱 Description
Remove(String, String)

從快取中移除快取專案。

Remove(String, CacheEntryRemovedReason, String)

使用原因從快取中移除快取專案。

Remove(String, String)

從快取中移除快取專案。

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 項目,移除該項目會觸發所有相關的變更監控器。 若移除的項目與物件CacheItemUpdateCallbackCacheItemRemovedCallback相關聯,則傳入回調的原因為 Removed

適用於

Remove(String, CacheEntryRemovedReason, String)

使用原因從快取中移除快取專案。

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

適用於