À propos de PostSharp Caching

Améliorez les performances de vos applications .NET avec un attribut personnalisé simple.

PostSharp allows you to dramatically reduce the complexity of caching. It allows you to cache the return value of a method as a function of its arguments with just a custom attribute, namely the CacheAttribute aspect. The InvalidateCacheAttribute aspect and the CachingServices.Invalidation API offer a strongly-typed way to invalidate cached methods. Additionally, PostSharp is independent from the caching framework or server (called caching backend), so you can choose from several backends or implement an adapter for your own backend.

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
    • Code Contracts
  • MVVM
    • INotifyPropertyChanged: automatic properties
  • Logging
    • Developer mode (freshly-built apps)
  • Caching