MemoryCacheElement.CacheMemoryLimitMegabytes MemoryCacheElement.CacheMemoryLimitMegabytes MemoryCacheElement.CacheMemoryLimitMegabytes MemoryCacheElement.CacheMemoryLimitMegabytes Property


获取或设置 MemoryCache 对象的实例可增长到的最大内存大小(以兆字节为单位)。Gets or sets the maximum memory size, in megabytes, that an instance of a MemoryCache object can grow to.

 property int CacheMemoryLimitMegabytes { int get(); void set(int value); };
[System.Configuration.ConfigurationProperty("cacheMemoryLimitMegabytes", DefaultValue=Mono.Cecil.CustomAttributeArgument)]
public int CacheMemoryLimitMegabytes { get; set; }
member this.CacheMemoryLimitMegabytes : int with get, set
Public Property CacheMemoryLimitMegabytes As Integer


最大内存量(以兆字节为单位)。The amount of maximum memory size, in megabytes. 默认值为零,指示 MemoryCache 实例会基于计算机上安装的内存量来管理自己的内存。The default is zero, which indicates that MemoryCache instances manage their own memory based on the amount of memory that is installed on the computer.


CacheMemoryLimitMegabytes属性值表示cacheMemoryLimitMegabytes中的配置属性namedCaches配置元素。The CacheMemoryLimitMegabytes property value represents the cacheMemoryLimitMegabytes configuration attribute in the namedCaches configuration element.

如果缓存大小超过指定的限制,内存缓存实现中移除缓存项。If the cache size exceeds the specified limit, the memory cache implementation removes cache entries.

在中,可分别设置此属性namedCaches元素,与每个namedCaches对应的唯一缓存配置元素。This property can be set individually in namedCaches elements, with each namedCaches element corresponding to a unique cache configuration.

设置CacheMemoryLimit属性可以从读取cacheMemoryLimitMegabytes的配置文件中的配置属性。The settings for the CacheMemoryLimit property can be read from the cacheMemoryLimitMegabytes configuration attribute in the configuration file. 或者,设置可传递时MemoryCache初始化类。Alternatively, the settings can be passed when the MemoryCache class is initialized.

有关如何配置缓存的详细信息,请参阅 <namedCaches>元素 (缓存设置)For more information about how to configure the cache, see <namedCaches> Element (Cache Settings).