<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.

<configuration> Element
  <system.runtime.caching> Element (Cache Settings)
    <memoryCache> Element (Cache Settings)
      <namedCaches> Element (Cache Settings)
<namedCaches>
  <add name="default" 
</namedCaches>

None

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

CacheMemoryLimitMegabytes

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.

Name

The name of the cache.

PhysicalMemoryLimitPercentage

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.

PollingInterval

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.

Child Elements

Element

Description

<add>

Adds a named cache to the namedCaches collection for a memory cache.

<clear>

Clears the namedCaches collection for a memory cache.

<remove>

Removes a named cache entry from the namedCaches collection for a memory cache.

Parent Elements

Element

Description

<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 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>
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft