MemoryCache.GetCacheItem(String, String) 方法

定義

CacheItem 執行個體形式從快取傳回指定的項目。

public override System.Runtime.Caching.CacheItem GetCacheItem (string key, string regionName = default);
override this.GetCacheItem : string * string -> System.Runtime.Caching.CacheItem
Public Overrides Function GetCacheItem (key As String, Optional regionName As String = Nothing) As CacheItem

參數

key
String

要取得之快取項目的唯一識別項。

regionName
String

快取區中的具名區域,已將快取項目加入其中。 請勿傳遞這個參數的值。 這個參數預設為 null,因為 MemoryCache 類別沒有實作區域。

傳回

如果由 key 所識別的快取項目存在,則為該快取項目的參考,否則為 null

例外狀況

regionName 不是 null

keynull

備註

如果 所 key 指定的快取專案存在於快取中,則方法會將 GetCacheItem 它當做 CacheItem 實例傳回。 Key將會設定 實例的 CacheItemValue 屬性。 不過, RegionName 屬性會是 null,因為區域不會在 類別中實作 MemoryCache

適用於