ObjectCache::AddOrGetExisting Method

.NET Framework (current version)
 

When overridden in a derived class, tries to insert a cache entry into the cache, and returns an existing cache entry with a matching key.

Namespace:   System.Runtime.Caching
Assembly:  System.Runtime.Caching (in System.Runtime.Caching.dll)

NameDescription
System_CAPS_pubmethodAddOrGetExisting(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.

System_CAPS_pubmethodAddOrGetExisting(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.

System_CAPS_pubmethodAddOrGetExisting(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.

The AddOrGetExisting method overloads insert an entry into the cache. If a cache entry with a matching key already exists, they return the existing entry. The cache entry can be a CacheItem object or a generic object.

There is one difference between the AddOrGetExisting overloads and the Add overloads. When these overloaded methods try to insert a cache entry, if an existing entry is found that has a key that matches an existing inserted cache entry, the AddOrGetExisting overloads return the existing cache entry. The Add overloads do not.

Return to top
Show: