Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从配置文件控制CacheItemPolicy属性-可能吗?_C#_.net_Vb.net_Caching_.net 4.0 - Fatal编程技术网

C# 从配置文件控制CacheItemPolicy属性-可能吗?

C# 从配置文件控制CacheItemPolicy属性-可能吗?,c#,.net,vb.net,caching,.net-4.0,C#,.net,Vb.net,Caching,.net 4.0,参考.NET 4.0中的System.Runtime.Caching类,似乎可以仅将配置文件中有限的内容设置为: 名字 轮询间隔 允许该缓存使用的内存量 清除缓存之前需要命中的内存百分比 示例部分如下所示: <system.runtime.caching> <memoryCache> <namedCaches> <add name="NameOfMyCache" pollingInterval="00:05:00

参考.NET 4.0中的System.Runtime.Caching类,似乎可以仅将配置文件中有限的内容设置为:

  • 名字
  • 轮询间隔
  • 允许该缓存使用的内存量
  • 清除缓存之前需要命中的内存百分比
示例部分如下所示:

 <system.runtime.caching>
    <memoryCache>
      <namedCaches>
        <add name="NameOfMyCache" pollingInterval="00:05:00" cacheMemoryLimitMegabytes="0" physicalMemoryLimitPercentage="0"/>
      </namedCaches>
    </memoryCache>
  </system.runtime.caching>

然而,似乎所有真正有用的项目(IMHO!)都无法从配置文件中控制。这些都是CacheItemPolicy类中的选项,例如AbsoluteExpiration、SlidingExpiration和Priority(我可以理解回调函数是如何不公开的,尽管我希望看到一些选项,说明在调用回调函数时应该做些什么)


问题是,是否可以从配置文件中执行此操作,而无需离开并滚动您自己的自定义部分?

似乎不可能,因此在此提交了一个连接案例:您连接案例链接已失效。。。我会投赞成票的。事实上是这样的,而且似乎投票赞成的情况已经不存在了。一定有一些病例被剔除了。谢谢你的提醒-谢谢!