Caching is a great way to improve the latency an application. Traditionally, when you implement caching, you need to play with the API of the caching framework (such as MemoryCache) or caching server (such as Redis) and to include moderately complex logic to your source code to generate the cache key, check the existence of the item in the cache, and add the item into the cache. Another source of complexity stems from removing items from the cache when the source data is updated. Implementing caching manually is not only time-consuming, but also is error-prone: it is easy to generate inconsistent cache keys between read and update methods.
With PostSharp Caching you can cache your methods with just a simple custom attribute:
- Improve application performance without adding repetitive code.
- Reduce cache key generation bugs.
- Support for C# MemoryCache, Redis Cache, Pub/Sub, and more.
- Customizable. Plug in your own cache storage.
Declarative caching and invalidation
- Add caching to a method with a simple custom attribute.
- Cache key automatically generated based on method name and parameter values.
- Invalidate cached method with custom attribute and automatic, build-time parameter matching.
- Fully customizable.
Object-oriented invalidation
- Improve seperation of concerns between readers and updaters.
- Dependencies of called methods automatically added to the caller context.
PostSharp Caching Features
- Framework
- Method-level aspects
- Code validation
- Common
- MVVM
- INotifyPropertyChanged: automatic properties
- Logging
- Developer mode (freshly-built apps)
- Caching