ObjectCache 類別

定義

表示物件快取,並提供存取物件快取所需的基底方法和屬性。Represents an object cache and provides the base methods and properties for accessing the object cache.

public ref class ObjectCache abstract : System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<System::String ^, System::Object ^>>
public abstract class ObjectCache : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,object>>
type ObjectCache = class
    interface seq<KeyValuePair<string, obj>>
    interface IEnumerable
Public MustInherit Class ObjectCache
Implements IEnumerable(Of KeyValuePair(Of String, Object))
繼承
ObjectCache
衍生
實作

備註

ObjectCache類型是記憶體內建物件快取的主要類型。The ObjectCache type is the primary type for the in-memory object cache. 若要開發自訂快取實作為, 您ObjectCache可以從類別衍生。To develop a custom cache implementation, you derive from the ObjectCache class.

注意

類別是的新.NET Framework 4.NET Framework 4的。 ObjectCacheThe ObjectCache class is new as of the .NET Framework 4.NET Framework 4.

MemoryCache建類別衍生ObjectCache自類別。The built-in MemoryCache class derives from the ObjectCache class. 類別是衍生自ObjectCache類別之.NET Framework 4.NET Framework 4中唯一的具體物件快取實作為。 MemoryCacheThe MemoryCache class is the only concrete object cache implementation in the .NET Framework 4.NET Framework 4 that derives from the ObjectCache class.

給實施者的注意事項

因為類型ObjectCache只代表一般的快取函式ObjectCache , 所以不需要具現化和取得實例的方式。Because the ObjectCache type represents only common cache functions, there is no requirement for how an ObjectCache instance must be instantiated and obtained. 此外, 也不需要單次個體ObjectCache類別的具體執行。In addition, there is no requirement that concrete implementations of the ObjectCache class must be singletons.

MemoryCache不是單一的, 但您應該只建立一個或僅有一個MemoryCache實例, 而快取專案的程式碼應該使用這些實例。MemoryCache is not a singleton, but you should create only a few or potentially only one MemoryCache instance and code that caches items should use those instances.

當您繼承自ObjectCache類別時, 您必須覆寫其方法。When you inherit from the ObjectCache class, you must override its methods.

建構函式

ObjectCache()

從衍生類別的建構函式進行呼叫,以初始化 ObjectCache 類別。Called from constructors in derived classes in order to initialize the ObjectCache class.

欄位

InfiniteAbsoluteExpiration

取得值,這個值表示快取項目沒有絕對期限。Gets a value that indicates that a cache entry has no absolute expiration.

NoSlidingExpiration

表示快取項目沒有滑動期限。Indicates that a cache entry has no sliding expiration time.

屬性

DefaultCacheCapabilities

在衍生類別中遭覆寫時,取得快取實作提供之功能描述。When overridden in a derived class, gets a description of the features that a cache implementation provides.

Host

取得或設定受控裝載環境的參考,該環境可用於 ObjectCache 實作,並可為 ObjectCache 實作提供主機專屬的服務。Gets or sets a reference to a managed hosting environment that is available to ObjectCache implementations and that can provide host-specific services to ObjectCache implementations.

Item[String]

取得或設定 ObjectCache 類別的預設索引子。Gets or sets the default indexer for the ObjectCache class.

Name

取得特定 ObjectCache 執行個體的名稱。Gets the name of a specific ObjectCache instance.

方法

Add(CacheItem, CacheItemPolicy)

在衍生類別中遭覆寫時,嘗試在快取區中插入做為 CacheItem 執行個體的快取項目,並加入項目清除方式的詳細資訊。When overridden in a derived class, tries to insert a cache entry into the cache as a CacheItem instance, and adds details about how the entry should be evicted.

Add(String, Object, CacheItemPolicy, String)

在衍生類別中遭覆寫時,在快取中插入快取項目,並指定關於要如何收回項目的資訊。When overridden in a derived class, inserts a cache entry into the cache, specifying information about how the entry will be evicted.

Add(String, Object, DateTimeOffset, String)

在衍生類別中覆寫時,在快取中插入快取項目,但不覆寫任何現有的快取項目。When overridden in a derived class, inserts a cache entry into the cache without overwriting any existing cache entry.

AddOrGetExisting(CacheItem, CacheItemPolicy)

在衍生類別中遭覆寫時,將指定的 CacheItem 物件插入至快取中,並指定關於要如何收回項目的資訊。When overridden in a derived class, inserts the specified CacheItem object into the cache, specifying information about how the entry will be evicted.

AddOrGetExisting(String, Object, CacheItemPolicy, String)

在衍生類別中遭覆寫時,在快取中插入快取項目,並指定快取項目的索引鍵和值,以及關於要如何收回項目的資訊。When overridden in a derived class, inserts a cache entry into the cache, specifying a key and a value for the cache entry, and information about how the entry will be evicted.

AddOrGetExisting(String, Object, DateTimeOffset, String)

在衍生類別中遭覆寫時,利用索引鍵、快取項目物件、絕對逾期值以及要將快取加入至的選擇性區域,將快取項目插快取取區中。When overridden in a derived class, inserts a cache entry into the cache, by using a key, an object for the cache entry, an absolute expiration value, and an optional region to add the cache into.

Contains(String, String)

在衍生類別中遭覆寫時,檢查快取項目是否已經存在於快取中。When overridden in a derived class, checks whether the cache entry already exists in the cache.

CreateCacheEntryChangeMonitor(IEnumerable<String>, String)

在衍生類別中遭覆寫時建立 CacheEntryChangeMonitor 物件,此物件可觸發事件以回應特定快取項目的變更。When overridden in a derived class, creates a CacheEntryChangeMonitor object that can trigger events in response to changes to specified cache entries.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Get(String, String)

在衍生類別中遭覆寫時,從快取區中取得做為物件的指定快取項目。When overridden in a derived class, gets the specified cache entry from the cache as an object.

GetCacheItem(String, String)

在衍生類別中遭覆寫時,從快取區中取得做為 CacheItem 執行個體的指定快取項目。When overridden in a derived class, gets the specified cache entry from the cache as a CacheItem instance.

GetCount(String)

在衍生類別中遭覆寫時,取得快取區中快取項目的總數。When overridden in a derived class, gets the total number of cache entries in the cache.

GetEnumerator()

在衍生類別中遭覆寫時建立列舉程式,這個列舉程式可以用來逐一查看快取項目的集合。When overridden in a derived class, creates an enumerator that can be used to iterate through a collection of cache entries.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetValues(IEnumerable<String>, String)

在衍生類別中遭覆寫時,取得對應至指定索引鍵的快取項目組。When overridden in a derived class, gets a set of cache entries that correspond to the specified keys.

GetValues(String, String[])

取得對應至指定索引鍵的快取項目組。Gets a set of cache entries that correspond to the specified keys.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(String, String)

在衍生類別中遭覆寫時,從快取區中移除快取項目。When overridden in a derived class, removes the cache entry from the cache.

Set(CacheItem, CacheItemPolicy)

在衍生類別中遭覆寫時,在快取中插入快取項目做為 CacheItem 執行個體,並指定關於要如何收回項目的資訊。When overridden in a derived class, inserts the cache entry into the cache as a CacheItem instance, specifying information about how the entry will be evicted.

Set(String, Object, CacheItemPolicy, String)

在衍生類別中遭覆寫時,在快取區中插入快取項目。When overridden in a derived class, inserts a cache entry into the cache.

Set(String, Object, DateTimeOffset, String)

在衍生類別中遭覆寫時,在快取中插入快取項目,並指定以時間為基礎的到期詳細資訊。When overridden in a derived class, inserts a cache entry into the cache, specifying time-based expiration details.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

IEnumerable.GetEnumerator()

支援泛型集合上的反覆運算。Supports iteration over a generic collection.

IEnumerable<KeyValuePair<String,Object>>.GetEnumerator()

支援在強類型集合上反覆運算。Supports iteration over a strongly typed collection.

擴充方法

CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於

執行緒安全性

此型別具備執行緒安全。This type is thread safe.