<namedCaches> Element (Cache Settings)
Specifies a collection of configuration settings for the named MemoryCache instances. The NamedCaches property references the collection of configuration settings from one or more
namedCaches elements of the configuration file.
<namedCaches> <add name="default" </namedCaches>
The following sections describe attributes, child elements, and parent elements.
|An integer value that specifies the maximum allowable size, in megabytes, that an instance of a MemoryCache can grow to. The default value is 0, which means that the autosizing heuristics of the MemoryCache class are used by default.|
|The name of the cache.|
|An integer value between 0 and 100 that specifies the maximum percentage of physically installed computer memory that can be consumed by the cache. The default value is 0, which means that the autosizing heuristics of the MemoryCache class are used by default.|
|A value that indicates the time interval after which the cache implementation compares the current memory load against the absolute and percentage-based memory limits that are set for the cache instance. This value is entered in "HH:MM:SS" format.|
|<add>||Adds a named cache to the |
|<clear>||Clears the |
|<remove>||Removes a named cache entry from the |
|<memoryCache>||Defines an element that is used to configure a cache that is based on the MemoryCache class.|
The memory cache configuration section of the Web.config file can contain
clear attributes for the
namedCaches collection. Each
namedCaches entry is uniquely identified by the
You can retrieve instances of memory cache entries by referencing the information in the application configuration files. By default, only the default cache instance has an entry in the configuration file. The default cache instance is the instance that is returned from the Default property.
If you set the name attribute to "default", the element uses the default memory cache instance.
The following example shows how to set the name of the cache 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 autosizing heuristics of the MemoryCache class are used. The cache implementation compares 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>