MemoryCache.Remove 方法

定義

從快取中移除指定的項目。Removes the specified item from the cache.

多載

Remove(String, String)

從快取中移除一個快取項目。Removes a cache entry from the cache.

Remove(String, CacheEntryRemovedReason, String)

使用原因,從快取中移除快取項目。Removes a cache entry from the cache using the reason.

Remove(String, String)

從快取中移除一個快取項目。Removes a cache entry from the cache.

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 = null) As Object

參數

key
String

要移除之快取項目的唯一識別項。A unique identifier for the cache entry to remove.

regionName
String

快取區中的具名區域,已將快取項目加入其中。A named region in the cache to which a cache entry was added. 請勿傳遞這個參數的值。Do not pass a value for this parameter. 這個參數預設為 null,因為 MemoryCache 類別沒有實作區域。This parameter is null by default, because the MemoryCache class does not implement regions.

傳回

如果在快取中找到快取項目,則移除該項目,否則為 nullIf the entry is found in the cache, the removed cache entry; otherwise, null.

例外狀況

regionName 不是 nullregionName is not null.

keynullkey is null.

備註

如果 key 所指定的專案存在於快取中,則移除該專案會觸發任何相關聯的變更監視。If the entry specified by key exists in the cache, removing the item triggers any associated change monitors. 如果移除的專案與 CacheItemUpdateCallback 物件或 CacheItemRemovedCallback 物件相關聯,則會 Removed傳遞至回呼的原因。If the removed item was associated with a CacheItemUpdateCallback object or a CacheItemRemovedCallback object, the reason passed to the callback is Removed.

Remove(String, CacheEntryRemovedReason, String)

使用原因,從快取中移除快取項目。Removes a cache entry from the cache using the reason.

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 = null) As Object

參數

key
String

要移除之快取項目的唯一識別項。A unique identifier for the cache entry to remove.

reason
CacheEntryRemovedReason

已移除項目的原因。The reason the item was removed.

regionName
String

快取區中的具名區域,已將快取項目加入其中。A named region in the cache to which a cache entry was added. 請勿傳遞這個參數的值。Do not pass a value for this parameter. 這個參數預設為 null,因為 MemoryCache 類別沒有實作區域。This parameter is null by default, because the MemoryCache class does not implement regions.

傳回

如果在快取中找到快取項目,則移除該項目,否則為 nullIf the entry is found in the cache, the removed cache entry; otherwise, null.

適用於