ObjectCache.AddOrGetExisting Method

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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: