监控企业库高速缓存 [英] Monitoring Enterprise Library caching
问题描述
我要监视被存储在我的企业库缓存机制应用的关键名称和值。
I want to monitor the key names and values that are being stored by my application in the Enterprise Library caching mechanism.
我们会在内存设置使用。基本上,我只需要弄清楚如何转储当前存储键。
We're using the in memory settings. Basically, I just need to figure out how to dump the keys that are currently stored.
我看到的ICacheManager返回具有一个计数器的对象,但也不会出现被访问缓存项目,除非你已经知道密钥的一种方法。
I see that the ICacheManager returns an object that has a counter, but there doesn't appear to be a way to access the cached items unless you already know the key.
想法?
推荐答案
您是正确的 - 企业库不公开CashManager的内存中缓存。但是......总有一个变通。可以参考所下载的来源作为项目修改原始的CacheManager来暴露缓存具有叫做CurrentCacheState属性和仅仅是一个哈希表的实例。
那么你会做平常的foreach:
You are correct - Enterprise Lib does not expose the in memory Cache of the CashManager. But... there is always a work around. You can reference the downloaded sourced as a project modify the original CacheManager to expose the instance of cache which has a property called CurrentCacheState and is a mere hashtable. Then you would do the usual foreach:
foreach(DictionaryEntry d in myExposedCacheManager.RealCache.CurrentCacheState)
{
Console.WriteLine(d.Key.ToString(), d.Value.ToString();
}
这篇关于监控企业库高速缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!