<add> Element for <namedCaches>

Adds a namedCache entry to the namedCaches collection for a memory cache.

<configuration>
  <system.runtime.caching>
    <memoryCache>
      <namedCaches>
        <add>

Syntax

<namedCaches>  
    <add name="Default" />  
      <!-- child elements -->  
 </namedCaches>  

Type

None

Attributes and Elements

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

Attributes

Attribute Description
CacheMemoryLimitMegabytes An integer value that specifies the maximum allowed size (in megabytes) that an instance of a MemoryCache can grow to. The default value is 0, which means that the MemoryCache class's autosizing heuristics 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 MemoryCache class's autosizing heuristics 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

None

Parent Elements

Element Description
<namedCaches> Contains a collection of configuration settings for the named MemoryCache instances.

Remarks

The add element adds an entry to the namedCaches collection for a memory cache. You can use the clear element before you use the add element to be certain that there are no other named caches in the collection. This element can be used in the machine.config file and in the Web.config file.

Example

The following example shows how to define settings for the default namedCache entry to the namedCaches collection for a memory cache.

<configuration>  
  
  <system.runtime.caching>  
    <memoryCache>  
      <namedCaches>  
          <add name="Default"
               cacheMemoryLimitMegabytes="0"
               physicalMemoryPercentage="0"  
               pollingInterval="00:02:00" />  
      </namedCaches>  
    </memoryCache>  
  </system.runtime.caching>  
  
</configuration>  

See also