<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.
Attributes and Elements
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.
Adds a named cache to the namedCaches collection for a memory cache.
Clears the namedCaches collection for a memory cache.
Removes a named cache entry from the namedCaches collection for a memory cache.
The memory cache configuration section of the Web.config file can contain add, remove, and clear attributes for the namedCaches collection. Each namedCaches entry is uniquely identified by the name attribute.
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".
The 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>