Dynamic creation of CacheManager objects?

Topics: Caching Application Block
Jun 29, 2007 at 2:51 PM
Is there a way to dynamically create CacheManager objects? From what I've read, it seems that we can only create CacheManagers by specifying them in advance in a config file. I don't know how many CacheManagers I require until runtime. How can I do this?
Jun 29, 2007 at 9:00 PM
Hi,

You could create the parts used by a CacheManager and assemble them (see CacheManagerFactoryHelper.BuildCacheManager to see how this is assembled), or set up a DictionaryConfigurationSource with the configuration objects describing the CacheManager you need and feed the configuration source into a new CacheManagerFactory to build the manager for you. With the second approach you would still be relying on configuration, just not on a static configuration file, and you would also get singleton management as long as you keep a reference to the factory.
You wouldn't be able to use the static CacheFactory though.

Hope this helps,
Fernando