Binding a Control to CacheManager's cache

Topics: Caching Application Block
Mar 14, 2008 at 3:28 PM
Question regarding access to the cache in the Caching Application Block:

I want to set the DataSource property of a BindingSource instance to the Hastable (or cache) controlled by the CacheManager. However, an instance of the CacheManager does not provide a public member to access its cache's state. Interestingly, the Cache class itself has a public method called CurrentCacheState() that returns a clone of its hashtable.

Given that all caching operations are performed through a CacheManager, as recommended by the documentation, do I have to modify the CacheManager source code to grant me access to its cache's current state? Otherwise, how does one access the public members of the Cache class via the CacheManager?


Mar 14, 2008 at 9:28 PM
I went ahead and modified the original CacheManager.cs source, adding a public property to expose the in-memory cache. However, there must have been a good reason why the in-memory cache was not exposed in the first place, so if anyone has any comments, please post.

Thanks again.
Mar 21, 2008 at 3:32 PM
Hi Klaus,

The in-memory cache is really a private implementation detail of the CacheManager class. Keep in mind that items in this in memory cache might be scavenged or expired at any time.