禁用 MvcSiteMapProvider 缓存
MvcSiteMapProvider 似乎会发生自动缓存。是否有禁用缓存的机制?我们编写了自定义缓存例程,我想通过这些例程来运行它,而不是依赖于任何内置的缓存机制。
There seems to be automatic caching that happens with MvcSiteMapProvider. Is there a mechanism to disable caching? We have custom caching routines written and I want to run it through those instead of relying on any built in caching mechanism.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试在渲染菜单或站点地图之前调用刷新。
Try to call Refresh before render menu or sitemap.
在 MvcSiteMapProvider v4 中,缓存现在可以扩展或替换为您自己的实现。看看我写的以下博客文章。
MvcSiteMapProvider 4.0 - 扩展缓存
现在,它在幕后使用 System.Runtime.Caching.ObjectCache,这是一个抽象类,可以由您选择的缓存管理器替换。
In MvcSiteMapProvider v4, the cache can now be extended or replaced with your own implementation. Have a look at the following blog post that I wrote.
MvcSiteMapProvider 4.0 - Extending the Cache
Under the covers it now uses System.Runtime.Caching.ObjectCache, an abstract class that can be replaced by a cache manager of your choosing.
查看源代码,在构建站点地图时总是会创建一个缓存项,并将该项存储在
HttpContext.Current.Cache
中。此缓存项的生命周期是通过配置cacheDuration
中的属性进行配置的。如果配置中省略此属性,则默认为 5。尝试将该配置属性设置为 0。Looking over the source, a cache item is always created when the sitemap is built, storing the item in
HttpContext.Current.Cache
. The lifetime of this cache item is configured from a property in the configurationcacheDuration
. If this attribute is omitted from the configuration, it defaults to 5. Try setting that configuration attribute to 0.有点老套,但谁在乎:
A bit hacky but who cares: