Cache Factory Not Returning Custom CacheManager

Topics: Building and extending application blocks, Caching Application Block , General discussion
Apr 16, 2009 at 1:20 PM
I've created a custom cache manager that interfaces with a custom cache class and backing store class. The cache manager implements ICacheManager and includes the  <ConfigurationElementType(GetType(CustomCacheManagerData))> attribute. However when I use the cache factory to create an instance of my custom cache manager using:


_customCacheManager=CacheFactory.GetCacheManager("Custom Cache Manager")


 

the factory always returns "CacheManager" instead of my custom cache manager (CustomCacheManager). The config section for "Custom Cache Manager" looks like the following:

<add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"

numberToRemoveWhenScavenging="10" backingStoreName="Directory Storage"

type="MyCompany.CustomCacheManager, MyCompany.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

name="Custom Cache Manager" />

 

"Here's the section for Directory Storage":

<add BaseDir="Users" UserSpecific="True" encryptionProviderName=""

type="MyCompany.BackingStoreImplementations.CustomBackingStore, MyCompany.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

name="Directory Storage" />

 
Anybody got any ideas?

Apr 17, 2009 at 5:11 AM
Hi,

I tried to create a custom cache manager to repro your problem, but it gives me the custom class and not the "CacheManager", I just added a custom cache manager on the CAB in the config. and instantiate it like this: 

ICacheManager

mngr = CacheFactory.GetCacheManager("Custom Cache Manager");

Do you have other cache manager other than the Custom? Also can you post your full config file?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Apr 21, 2009 at 3:14 PM
FYI, I got it working...I mistakenly typed in "CacheManagerData" instead of "CustomCacheManagerData" in the ConfigurationElementType attribute. Once I made the change it worked like a champ.