A set of extensions to provide caching support on MediatR based request handlers.
You should install Cacheable with NuGet:
Install-Package Cacheable
This command will download and install Cacheable. Let me know if you have questions!
Cacheable requires MediatR and your IoC container of choice. The decorator pattern is used to wrap the IRequestHandler
and IAsyncRequestHandler
classes with Cacheable implementations that will handle the caching.
For(typeof(IRequestHandler<,>)).DecorateAllWith(typeof(MemoryCacheRequestHandler<,>));
For(typeof(IAsyncRequestHandler<,>)).DecorateAllWith(typeof(MemoryCacheAsyncRequestHandler<,>));