[英]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.
基本上,我只需要弄清楚如何转储当前存储的密钥。
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. 我看到ICacheManager返回了一个带有计数器的对象,但是除非您已经知道密钥,否则似乎没有一种访问缓存项的方法。
Ideas? 有想法吗?
You are correct - Enterprise Lib does not expose the in memory Cache of the CashManager. 您是正确的-Enterprise Lib不会公开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.
您可以引用下载的源文件,该文件是作为项目修改原始CacheManager来公开的缓存实例,该实例具有名为CurrentCacheState的属性,仅是哈希表。 Then you would do the usual foreach:
然后,您将执行通常的foreach:
foreach(DictionaryEntry d in myExposedCacheManager.RealCache.CurrentCacheState)
{
Console.WriteLine(d.Key.ToString(), d.Value.ToString();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.