<添加 > 元素<namedCaches ><add> Element for <namedCaches>

将添加namedCache进入namedCaches内存缓存的集合。Adds a namedCache entry to the namedCaches collection for a memory cache.

<system.runtime.caching><system.runtime.caching>
<memoryCache><memoryCache>
<namedCaches><namedCaches>
<add><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 一个整数值,指定的最大允许大小 (以兆字节为单位) 的实例MemoryCache可以增长到。An integer value that specifies the maximum allowed size (in megabytes) that an instance of a MemoryCache can grow to. 默认值为 0,这意味着MemoryCache默认情况下使用类的自动调整大小试探法。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 一个整数值介于 0 和 100 之间,指定可以使用由缓存以物理方式安装的计算机内存的最大百分比。An integer value between 0 and 100 that specifies the maximum percentage of physically installed computer memory that can be consumed by the cache. 默认值为 0,这意味着MemoryCache默认情况下使用类的自动调整大小试探法。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. "Hh: mm:"格式输入此值。This value is entered in "HH:MM:SS" format.

子元素Child Elements

None

父元素Parent Elements

元素Element 描述Description
<namedCaches><namedCaches> 包含的配置设置的命名集合MemoryCache实例。Contains a collection of configuration settings for the named MemoryCache instances.

备注Remarks

add元素添加一个条目namedCaches内存缓存的集合。The add element adds an entry to the namedCaches collection for a memory cache. 可以使用清除元素在使用之前add元素以确认是否不存在任何其他命名缓存在集合中的。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. 在 machine.config 文件中并在 Web.config 文件中,可以使用此元素。This element can be used in the machine.config file and in the Web.config file.

示例Example

下面的示例演示如何定义的默认设置namedCache进入namedCaches内存缓存的集合。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