如何刷新 EntLib 缓存进程中的所有缓存

发布于 2024-07-11 03:17:40 字数 156 浏览 6 评论 0原文

我想知道是否有一种方法可以告诉企业库缓存对象刷新所有配置的缓存以刷新该进程。

即使枚举该进程的所有已配置缓存,并手动刷新每个缓存,也可以,但是 EntLib.Caching 是否有一种 API 方法可以为我提供这些值?

或者我需要自己通过配置文件进行枚举吗?

I'd like to know if there is a way to tell the Enterprise Library Caching objects to flush all configured caches for that process to flush.

Even enumerating through all of the configured caches for that process, and manually flushing each one, is ok, but is there an API method from EntLib.Caching that will give me those values?

Or do I need to enum through the config file myself?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

堇年纸鸢 2024-07-18 03:17:40

这个怎么样:

CacheManagerSettings conf = (CacheManagerSettings)ConfigurationSourceFactory.Create()
    .GetSection(CacheManagerSettings.SectionName);

conf.CacheManagers.ForEach(delegate(CacheManagerDataBase cache) { 
        CacheFactory.GetCacheManager(cache.Name).Flush();
    });

How about this:

CacheManagerSettings conf = (CacheManagerSettings)ConfigurationSourceFactory.Create()
    .GetSection(CacheManagerSettings.SectionName);

conf.CacheManagers.ForEach(delegate(CacheManagerDataBase cache) { 
        CacheFactory.GetCacheManager(cache.Name).Flush();
    });
放血 2024-07-18 03:17:40

我不认为有办法刷新所有缓存。 回收应用程序池可以做到这一点,但这也会导致您的代码需要 JIT 编译。

我们通常将缓存的名称存储在常量中,以避免名称在代码中的多个位置进行硬编码,如果将名称存储在可枚举数据类型中,则可以一次遍历它并刷新它们。

I do not think that there is a way to flush all caches. Recycling the application pool would do it, but this would also cause your code to require a JIT compile.

We normally store the names of the caches in constants, to avoid the name being hardcoded several places in the code, if you store the names in an enumerable data type you could just go through it and flush them one at a time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文