且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

监控企业库高速缓存

更新时间:2022-03-27 22:43:16

您是正确的 - 企业库不公开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();
    }