ASP.Net的AppFabric缓存缺失冲洗/清除和计数/ getCount方法可?

编程入门 行业动态 更新时间:2024-10-26 09:19:31
本文介绍了ASP.Net的AppFabric缓存缺失冲洗/清除和计数/ getCount方法可?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图用EntLib的解决方案转换为使用AppFabric缓存。通过几扩展方法的帮助,这是一个相当无痛苦的过程。

I am trying to convert a solution using EntLib into using AppFabric caching. By help of a few extension methods this is a fairly pain-free process.

扩展方法我用:

public static bool Contains(this DataCache dataCache, string key) { return dataCache.Get(key) != null; } public static object GetData(this DataCache dataCache, string key) { return dataCache.Get(key); }

但也有EntLib的两个特点,我觉得很难转换。即计数(计数数缓存键)和刷新(从缓存中删除所有数据)。双方可以解决,如果我能在高速缓存中循环的关键。

But there are two features of EntLib I find difficult to convert. Namely "Count" (counting number of keys in cache) and "Flush" (removing all data from cache). Both could be solved if I could iterate the keys in cache.

有一个名为 ClearRegion(串区域)的方法,但这需要我就全部搞定/认沽/添加的方法我用指定的区域名称,这将需要一些手动容易出错的工作。

There is a method called ClearRegion(string region), but that required me to specify a region name on all Get/Put/Add-methods I use, which would require some manual error-prone work.

有没有办法让在高速缓存中的密钥列表? 有没有我可以使用默认的区域名称? 我怎样才能刷新缓存的时候我没有用一个区域名称?

Is there any way to get a list of keys in cache? Is there a default region name I can use? How can I flush the cache when I haven't used a region name?

推荐答案

请参阅my为previous答案我的炒作的作为缓存的内部工作原理,当你不指定区域,以及如何可以得到不在一个对象的个数命名的区域。

See my previous answer for my speculation as to how the cache works internally when you don't specify a region, and how you can get the count of objects that aren't in a named region.

我们可以使用相同的技术建立一个Flush方法:

We can build a Flush method using the same technique:

public void Flush (this DataCache cache) { foreach (string regionName in cache.GetSystemRegions()) { cache.ClearRegion(regionName) } }

正如我说有,我想叫区域是的可能的要走的路 - 这在我看来,使用它们解决更多的问题比它创建

As I said there, I think named regions are probably the way to go - it seems to me that using them solves more problems than it creates.

更多推荐

ASP.Net的AppFabric缓存缺失冲洗/清除和计数/ getCount方法可?

本文发布于:2023-11-13 21:44:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585399.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缺失   缓存   方法   Net   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!