<system.runtime.caching> Element (Cache Settings)
Provides configuration for the default in-memory ObjectCache implementation through the memoryCache entry in the configuration file.
<configuration> Element
<system.runtime.caching> Element (Cache Settings)
<system.runtime.caching >
<!-- child elements -->
</system.runtime.caching >
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Attributes
None
Child Elements
Element |
Description |
---|---|
Defines an element that is used to configure a cache that is based on the MemoryCache class. |
Parent Elements
Element |
Description |
---|---|
Specifies the root element in every configuration file that is used by the common language runtime and .NET Framework applications. |
Remarks
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.
Note
The output caching functionality and types in the System.Runtime.Caching namespace are new in .NET Framework version 4.
Example
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".
The 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>