<system.runtime.caching> Element (Cache Settings)
Provides configuration for the default in-memory ObjectCache implementation through the
memoryCache entry in the configuration file.
<system.runtime.caching > <!-- child elements --> </system.runtime.caching >
The following sections describe attributes, child elements, and parent elements.
|<memoryCache>||Defines an element that is used to configure a cache that is based on the MemoryCache class.|
|<configuration>||Specifies the root element in every configuration file that is used by the common language runtime and .NET Framework applications.|
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. For more information, see Caching in .NET Framework Applications.
The output caching functionality and types in the System.Runtime.Caching namespace are new in .NET Framework 4.
The following example shows how to configure a cache that is based on the MemoryCache class. The example shows how to configure an instance of the
namedCaches entry for memory cache. The name of the cache is set to the default cache entry name by setting the
name attribute to "default".
cacheMemoryLimitMegabytes attribute and the
physicalMemoryPercentage attribute are set to zero. Setting these attributes to zero means that the MemoryCache autosizing heuristics are used by default. The cache implementation should compare the current memory load against the absolute and percentage-based memory limits every two minutes.
<configuration> <system.runtime.caching> <memoryCache> <namedCaches> <add name="default" cacheMemoryLimitMegabytes="0" physicalMemoryPercentage="0" pollingInterval="00:02:00" /> </namedCaches> </memoryCache> </system.runtime.caching> </configuration>