CacheSection.DisableMemoryCollection 属性

定义

获取或设置一个值,该值指示是否禁用缓存内存集合。

public:
 property bool DisableMemoryCollection { bool get(); void set(bool value); };
[System.Configuration.ConfigurationProperty("disableMemoryCollection", DefaultValue=false)]
public bool DisableMemoryCollection { get; set; }
[<System.Configuration.ConfigurationProperty("disableMemoryCollection", DefaultValue=false)>]
member this.DisableMemoryCollection : bool with get, set
Public Property DisableMemoryCollection As Boolean

属性值

true 如果禁用缓存内存收集,则为否则,为 false. 默认值为 false

属性

示例

下面的代码示例演示如何使用该 DisableMemoryCollection 属性。

// Enable or disable memory collection.
cacheSection.DisableMemoryCollection = 
        !cacheSection.DisableMemoryCollection;
' Enable or disable memory collection.
cacheSection.DisableMemoryCollection =
    Not cacheSection.DisableMemoryCollection

注解

DisableMemoryCollection如果该属性设置为true,则对缓存相关 API 的调用将不起作用。

如果属性 DisableMemoryCollection 设置为 true,缓存不会尝试收集未使用的项。 使用此设置时请小心,因为禁用内存收集可以快速导致应用程序的内存不足情况。

此设置对 ASP.NET 内部缓存或输出缓存没有影响。 有关不同类型的缓存的详细信息,请参阅 缓存

适用于

另请参阅