Cache expensive methods calls with a declarative attribute. No custom code required.
[Cache.Cacheable] //this method now cached, will only be called once per guid
public SomeExpensiveObject GetExpensiveObject(Guid userId)
{
..
}
[Cache.Cacheable("UniqueKeyForThisMethod")] //cache using this key plus parameter(s)
public SomeObject GetObjectById(Int32 Id)
{
...
}
[Cache.TriggerInvalidation("UniqueKeyForThisMethod")] //delete from cache using this key and passed parameter(s)
public void RemoveObjectById(Int32 Id)
{
..
}
More examples can also be found here: http://cascadeofinsights.com/post/1410736927/introducing-attribute-based-caching
Using postsharp to make method interceptions when a cached version exists
- http://paulstack.co.uk/blog/post/Attribute-Based-Caching-with-PostSharp.aspx
- http://cascadeofinsights.com/post/1410736927/introducing-attribute-based-caching
- http://www.infoq.com/news/2011/04/Attribute-Caching
- http://www.postsharp.net/blog/post/Attribute-Based-Caching-and-Unit-Testing-of-Aspects
- http://stackoverflow.com/questions/5328819/caching-attribute-for-method
- Original Codeplex Release
- faster key generation strategy - thanks payman
- basic unit tests - thanks payman
- btree disk cache
- removed unity dependency
- simple timetolive setting
- adding ignoreTTL
- adding support for colection to KeyBuilder
- adding deconstructor to btreecache - to clean up open filestream
- add compile-time reflection cache attribute
- GitHub version is the most recent version