ObjectCache Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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))
- Inheritance
-
ObjectCache
- Derived
- Implements
Remarks
The ObjectCache type is the primary type for the in-memory object cache. To develop a custom cache implementation, you derive from the ObjectCache class.
Note
The ObjectCache class is new as of the .NET Framework 4.
The built-in MemoryCache class derives from the ObjectCache class. The MemoryCache class is the only concrete object cache implementation in the .NET Framework 4 that derives from the ObjectCache class.
Notes to Implementers
Because the ObjectCache type represents only common cache functions, there is no requirement for how an ObjectCache instance must be instantiated and obtained. In addition, there is no requirement that concrete implementations of the ObjectCache class must be singletons.
Note: 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.
When you inherit from the ObjectCache class, you must override its methods.
Constructors
| Name | Description |
|---|---|
| ObjectCache() |
Called from constructors in derived classes in order to initialize the ObjectCache class. |
Fields
| Name | Description |
|---|---|
| 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. |
Properties
| Name | Description |
|---|---|
| DefaultCacheCapabilities |
When overridden in a derived class, gets a description of the features that a cache implementation provides. |
| Host |
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] |
Gets or sets the default indexer for the ObjectCache class. |
| Name |
Gets the name of a specific ObjectCache instance. |
Methods
| Name | Description |
|---|---|
| Add(CacheItem, CacheItemPolicy) |
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) |
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) |
When overridden in a derived class, creates a CacheEntryChangeMonitor object that can trigger events in response to changes to specified cache entries. |
| Get(String, String) |
When overridden in a derived class, gets the specified cache entry from the cache as an object. |
| GetCacheItem(String, String) |
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. |
| 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. |
| Remove(String, String) |
When overridden in a derived class, removes the cache entry from the cache. |
| Set(CacheItem, CacheItemPolicy) |
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. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IEnumerable.GetEnumerator() |
Supports iteration over a generic collection. |
| IEnumerable<KeyValuePair<String,Object>>.GetEnumerator() |
Supports iteration over a strongly typed collection. |
Extension Methods
Applies to
Thread Safety
This type is thread safe.