MemoryCache 類別

定義

使用字典儲存其項目的 IMemoryCache 實作。

public ref class MemoryCache : IDisposable, Microsoft::Extensions::Caching::Memory::IMemoryCache
public class MemoryCache : IDisposable, Microsoft.Extensions.Caching.Memory.IMemoryCache
type MemoryCache = class
    interface IMemoryCache
    interface IDisposable
Public Class MemoryCache
Implements IDisposable, IMemoryCache
繼承
MemoryCache
實作

建構函式

MemoryCache(IOptions<MemoryCacheOptions>)

建立新的 MemoryCache 執行個體。

MemoryCache(IOptions<MemoryCacheOptions>, ILoggerFactory)

建立新的 MemoryCache 執行個體。

屬性

Count

取得目前項目的計數,以供診斷之用。

Keys

使用字典儲存其項目的 IMemoryCache 實作。

方法

Clear()

從快取中移除所有索引鍵和值。

Compact(Double)

使用字典儲存其項目的 IMemoryCache 實作。

CreateEntry(Object)

建立或覆寫快取中的項目。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

Dispose(Boolean)

處置快取並清除所有專案。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Finalize()

清除背景集合事件。

GetCurrentStatistics()

取得記憶體快取目前統計數據的快照集。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(Object)

移除與指定索引鍵建立關聯的物件。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TryGetValue(Object, Object)

取得與此索引鍵建立關聯的項目 (如有)。

擴充方法

Get(IMemoryCache, Object)

如果存在,取得與這個索引鍵相關聯的值。

Get<TItem>(IMemoryCache, Object)

如果存在,取得與這個索引鍵相關聯的值。

GetOrCreate<TItem>(IMemoryCache, Object, Func<ICacheEntry,TItem>)

如果索引鍵存在,則取得與這個索引鍵相關聯的值,或者如果找不到索引鍵,則從指定的處理站產生新的專案。

GetOrCreate<TItem>(IMemoryCache, Object, Func<ICacheEntry,TItem>, MemoryCacheEntryOptions)

使用字典儲存其項目的 IMemoryCache 實作。

GetOrCreateAsync<TItem>(IMemoryCache, Object, Func<ICacheEntry,Task<TItem>>)

如果存在,請以異步方式取得與此索引鍵相關聯的值,或者如果找不到索引鍵,則從指定的處理站產生新的專案。

GetOrCreateAsync<TItem>(IMemoryCache, Object, Func<ICacheEntry,Task<TItem>>, MemoryCacheEntryOptions)

使用字典儲存其項目的 IMemoryCache 實作。

Set<TItem>(IMemoryCache, Object, TItem)

將值與 中的 IMemoryCache指定索引鍵產生關聯。

Set<TItem>(IMemoryCache, Object, TItem, MemoryCacheEntryOptions)

將快取專案與指定的索引鍵產生關聯,並將現有 MemoryCacheEntryOptions 的值套用至已建立的專案。

Set<TItem>(IMemoryCache, Object, TItem, IChangeToken)

將快取專案與到期時 IChangeToken 到期的指定索引鍵產生關聯。

Set<TItem>(IMemoryCache, Object, TItem, DateTimeOffset)

建立或覆寫快取中指定的專案,並使用絕對到期日設定值。

Set<TItem>(IMemoryCache, Object, TItem, TimeSpan)

建立快取專案與指定索引鍵的關聯,該索引鍵將在指定的持續時間之後到期。

TryGetValue<TItem>(IMemoryCache, Object, TItem)

嘗試取得與指定索引鍵相關聯的值。

適用於