Share via


InMemoryCache Class

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

Represents the type that implements an in-memory cache.

Namespace: Microsoft.Practices.EnterpriseLibrary.Caching
Assembly: Microsoft.Practices.EnterpriseLibrary.Caching.Silverlight (in Microsoft.Practices.EnterpriseLibrary.Caching.Silverlight.dll) Version: 5.0.505.0

Syntax

public class InMemoryCache : MemoryBackedCacheBase<CacheEntry>
'Declaration
Public Class InMemoryCache _
    Inherits MemoryBackedCacheBase(Of CacheEntry)
public ref class InMemoryCache : public MemoryBackedCacheBase<CacheEntry^>

Remarks

The InMemoryCache class is a concrete implementation of the abstract ObjectCache class.

Note: The InMemoryCache class is somewhat similar to the System.Runtime.Caching.MemoryCache class available in the .NET Framework in the Desktop. The InMemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the Desktop's MemoryCache class. The MemoryCache class does not allow null as a value in the cache. Any attempt to add or change a cache entry with a value of null will fail.

The InMemoryCache type does not implement cache regions. Therefore, when you call InMemoryCache methods that implement base methods that contain a parameter for regions, do not pass a value for the parameter. The methods that use the region parameter all supply a default nulla null reference (Nothing in Visual Basic) value. For example, the AddOrGetExisting(String, Object, CacheItemPolicy, String) method overload has a regionName parameter whose default value is nulla null reference (Nothing in Visual Basic).

Inheritance Hierarchy

System.Object
  Microsoft.Practices.EnterpriseLibrary.Caching.Runtime.Caching.ObjectCache
    Microsoft.Practices.EnterpriseLibrary.Caching.InMemory.MemoryBackedCacheBase<CacheEntry>
      Microsoft.Practices.EnterpriseLibrary.Caching.InMemoryCache

See Also

InMemoryCache Members

Microsoft.Practices.EnterpriseLibrary.Caching Namespace