Project Description
Unity interception handler attribute for Caching which allows to apply boiler plate caching pattern to classes, and class members directly, without configuring them in the application configuration file.

Configure your choice of Cache Provider (ObjectCache, Azure included) in the Unity IoC Container and apply the attribute to the method which you want to cache



Example
//simply add the attribute and the method output will be cached for each unique argument list
[CachingCallHandler]
public IList<Product> GetFeaturedProducts(int categoryId)
{
...
}

//simply add the attribute and the method output will be cached for each unique argument list
[CachingCallHandler]
//specify a timeout for the cache item
[CacheTimeout(new TimeSpan(0, 5, 0), null)]
public IList<Product> GetFeaturedProducts(int categoryId)
{
...
}

//simply add the attribute and the method output will be cached for each unique argument list
[CachingCallHandler]
//specify a timeout for the cache item
[CacheTimeout(new TimeSpan(0, 5, 0), null)]
//append to the cache key any class member value or a fixed string
[AddToCacheKeyAttribute(ClassMember, "FixedValue")]
public IList<Product> GetFeaturedProducts(int categoryId)
{
...
}

//simply add the attribute and the method output will be cached for each unique argument list
[CachingCallHandler]
//specify a timeout for the cache item
[CacheTimeout(new TimeSpan(0, 5, 0), null)]
//append to the cache key any class member value or a fixed string
[AddToCacheKeyAttribute(ClassMember, "FixedValue")]
//IgnoreForCacheKey - do not use the argument to create the cache key
public IList<Product> GetFeaturedProducts([IgnoreForCacheKey]int categoryId)
{
...
}

Last edited May 10, 2012 at 11:56 PM by misbaharefin, version 4