Monitoring Enterprise Library caching

岁酱吖の 提交于 2019-12-10 12:11:00

问题


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.

Ideas?


回答1:


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();
    }


来源:https://stackoverflow.com/questions/4209479/monitoring-enterprise-library-caching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!