System.Runtime.Caching 中是否存在某种 CacheDependency?
我听说 .NET 4 有一个新的缓存 API。
好吧,原来的 System.Web.Caching.Cache(顺便说一下,.NET 4 中仍然存在)能够设置所谓的 CacheDependency > 用于确定缓存项是否过期的对象。
通过从 CacheDependency 派生自定义子类,还可以指定自定义逻辑来确定缓存项是否仍然可用。
我很好奇,有没有办法在新的 API 中提供这样的逻辑?
I heard that .NET 4 has a new caching API.
Okay, so the good old System.Web.Caching.Cache
(which is, by the way, still there in .NET 4) has the ability to set so-called CacheDependency
objects to determine whether a cached item is expired or not.
One can also specify custom logic for determining whether a cached item is still useable or not by deriving a custom subclass from CacheDependency
.
I'm curious, is there a way to provide such a logic in the new API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有真正使用它,但派生自 ChangeMonitor 的类Class 似乎有类似的用途。
I haven't really used it yet but classes derived from ChangeMonitor Class appear to serve a similar purpose.
将
System.Web.Caching.Cache
与CacheDependency
结合使用,构造如下:使用
System.Runtime.Caching
,这将移动到 <代码>CacheItemPolicy 更改监视器 。将上面的示例更改为以下内容:Using
System.Web.Caching.Cache
with aCacheDependency
was constructed something like the following:With
System.Runtime.Caching
this moves into theCacheItemPolicy
ChangeMonitors. The above example changes to the following: