caching block - Web Request caching

Topics: Caching Application Block
Sep 4, 2011 at 11:25 AM
Edited Sep 4, 2011 at 5:02 PM

I created a custom PassThroughCacheManager, the goal is for a web context (Current.Items/Current.Session) where I use the backing store as the lifetimemanager not the cachemanager.

 

	[ConfigurationElementType(typeof(CustomCacheManagerData))]
	public class PassThroughCacheManager : ICacheManager
	{
		private readonly NameValueCollection _collection;

		public PassThroughCacheManager(NameValueCollection collection)
		{
			_collection = collection;
		}

 

how do i access the configured backingstore so i can grab it by name given by:

_collection["backingStoreName"]

 

	<cachingConfiguration defaultCacheManager="InMemory">
		<backingStores>
			<add name="InMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching"/>
		</backingStores>

 

I am currently using:


        public PassThroughCacheManager(NameValueCollection collection)
        {
            var settings = ConfigurationManager.GetSection("cachingConfiguration") as CacheManagerSettings;
            var data = settings.BackingStores.Get(collection["backingStoreName"]);

// haven't finished but i had planned to use Activator.CreateInstance
        }

 

Is there a better way than going manually though ConfigurationManager.GetSection and using Activator.CreateInstance? 

What are your thoughts on my whole approach about creating PassThroughCacheManager so I can use storage that already has a lifetime associated with it... session/cookie/items

Sep 5, 2011 at 9:55 AM

Hi,

I'm not sure about your exact requirements, but it seems you need to integrate your custom cache manager to the config editor to hook it to the configured backing store. The basic integration only allows you to add key-value data. Kindly refer to this link for more details. Regarding with your first statement: "where I use the backing store as the lifetimemanager not the cachemanager.", can you elaborate this?

 

Noel Angelo Bolasoc
Avanade Software
Avanade, Inc.
Contact Us