GetCacheItem Method

MemoryCache.GetCacheItem Method (String, String)

.NET Framework (current version)
 

Returns the specified entry from the cache as a CacheItem instance.

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

override GetCacheItem : 
        key:string *
        regionName:string = null -> CacheItem

Parameters

key
Type: System.String

A unique identifier for the cache entry to get.

regionName
Type: System.String

A named region in the cache to which a cache entry was added. Do not pass a value for this parameter. This parameter is null by default, because the MemoryCache class does not implement regions.

Return Value

Type: System.Runtime.Caching.CacheItem

A reference to the cache entry identified by key if the entry exists; otherwise, null.

Exception Condition
NotSupportedException

regionName is not null.

ArgumentNullException

key is null.

If the cache entry specified by key exists in the cache, the GetCacheItem method returns it as a CacheItem instance. The Key and Value properties of the CacheItem instance will be set. However, the RegionName property will be null, because regions are not implemented in the MemoryCache class.

.NET Framework
Available since 4.0
Return to top
Show:
© 2016 Microsoft