Share via


MemoryCacheElement.CacheMemoryLimitMegabytes 属性

定义

获取或设置 MemoryCache 对象的实例可增长到的最大内存大小(以兆字节为单位)。

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

属性值

最大内存量(以兆字节为单位)。 默认值为零,指示 MemoryCache 实例会基于计算机上安装的内存量来管理自己的内存。

属性

注解

CacheMemoryLimitMegabytes属性值表示cacheMemoryLimitMegabytes配置元素中的namedCaches配置属性。

如果缓存大小超过指定的限制,则内存缓存实现将删除缓存条目。

可以在 元素中 namedCaches 单独设置此属性,每个 namedCaches 元素对应于唯一的缓存配置。

可以从配置文件中的 CacheMemoryLimit 配置属性读取 cacheMemoryLimitMegabytes 属性的设置。 或者,可以在初始化 类时 MemoryCache 传递设置。

有关如何配置缓存的详细信息,请参阅 <namedCaches> 元素 (缓存设置)

适用于

另请参阅