1 out of 4 rated this helpful Rate this topic

System.Runtime.Caching Namespace

The System.Runtime.Caching namespace contains types that let you implement caching in NET Framework applications.

The output caching functionality and types in the System.Runtime.Caching namespace are new in .NET Framework version 4. The classes in this namespace provide a way to use caching facilities like those in ASP.NET, but without a dependency on the System.Web assembly.

The caching types that are provided in this namespace offers the following features:

  • Caching is accessible to all .NET Framework applications, not just ASP.NET.

  • Caching is extensible.

  • You can create custom caching providers. For example, instead of using the default in-memory cache engine, you can create custom providers that store cache data in databases, in custom objects, or in the file system.

  Class Description
Public class CacheEntryChangeMonitor Provides a base class that represents a ChangeMonitor type that can be implemented in order to monitor changes to cache entries.
Public class CacheEntryRemovedArguments Provides information about a cache entry that was removed from the cache.
Public class CacheEntryUpdateArguments Provides information about a cache entry that will be removed from the cache.
Public class CacheItem Represents an individual cache entry in the cache.
Public class CacheItemPolicy Represents a set of eviction and expiration details for a specific cache entry.
Public class ChangeMonitor Provides a base class for a derived custom type that monitors changes in the state of the data which a cache item depends on.
Public class FileChangeMonitor Represents an object that monitors changes to files.
Public class HostFileChangeMonitor Monitors directories and file paths and notifies the cache of changes to the monitored items. This class cannot be inherited.
Public class MemoryCache Represents the type that implements an in-memory cache.
Public class ObjectCache Represents an object cache and provides the base methods and properties for accessing the object cache.
Public class SqlChangeMonitor Provides change monitoring for SQL Server databases. This class cannot be inherited.
  Delegate Description
Public delegate CacheEntryRemovedCallback Defines a reference to a method that is called after a cache entry is removed from the cache.
Public delegate CacheEntryUpdateCallback Defines a reference to a method that is invoked when a cache entry is about to be removed from the cache.
Public delegate OnChangedCallback Defines a reference to a method that handles changes to monitored items.
  Enumeration Description
Public enumeration CacheEntryRemovedReason Specifies the reason why a cache entry was removed or an entry is about to be removed.
Public enumeration CacheItemPriority Specifies a priority setting that is used to decide whether to evict a cache entry.
Public enumeration DefaultCacheCapabilities Represents a set of features that a cache implementation provides.

Reference

Other Resources

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Can not reference System.Runtime.Caching.dll
In some projects, it is not possible to reference System.Runtime.Caching.dll because these projects target the .NET Framework 4 Client Profile. This happens for example in WPF applications.
The target framework can be changed in Project Properties/Compile/Advanced Compiler Settings/Target Framework. To reference System.Runtime.Caching, the target framework must be set to .NET Framework 4.
Get Regions? GetCacheItems?
There seems to be no way to get any previously defined regions OR to iterate over the cached items.  This seems like a pretty basic oversight to me.
Comments DCR

There is no obvious discussion of threadsafety of the Cache.


Are all the caches provided threadsafe for addition and removal and refresh. ?