代码之家  ›  专栏  ›  技术社区  ›  Carlos A. Ibarra

设置ASP。C#服务中的网络缓存PrivateBytesLimit

  •  3
  • Carlos A. Ibarra  · 技术社区  · 17 年前

    我有一个C#服务,它不是ASP。NET应用程序,但使用HttpRuntime类的单例实例在其缓存成员中缓存项目。单例创建如下:

    static private System.Web.HttpRuntime _httpRuntime = new HttpRuntime();
    

    我想设置其最大内存使用量,以便在应用程序的配置文件service.exe.config中有以下内容:

    <configuration>
     <caching>
        <cache privateBytesLimit= "50000000"   privateBytesPollTime = "00:01:00"/>
     </caching>
    </configuration>
    

    这似乎没有任何效果。当我在HttpRuntime中查看时,没有将其设置为50MB。隐藏物。有效私有字节限制为720 MB。

    我做错了什么?

    1 回复  |  直到 17 年前
        1
  •  4
  •   sikander Zach Green    13 年前

    您没有使用正确的缓存元素。根据文件 EffectivePrivateBytesLimit 属性可以用privateBytesLimit属性设置 cache Element for caching (ASP.NET Settings Schema) element 在应用程序的配置文件中;

    <configuration>
      <system.web>
        <caching>
          <cache privateBytesLimit="10000000" privateBytesPollTime="00:01:00" />
        </caching>
      </system.web>
    </configuration>