Provider for caching using ASPNet OutputCache using LiteDatabase. Use with a ASP.NET Core port of StratWeb.CacheOutput library
Access our Nuget page
-
Install ASP.NET Core CacheOutput package: Install-Package AspNetCore.CacheOutput
-
Install core package: Install-Package AspNetCore.CacheOutput.LiteDB
-
In "Startup" class "ConfigureServices" method:
-
Register cache key generator:
services.AddSingleton<ICacheKeyGenerator, DefaultCacheKeyGenerator>();
-
Register the provider for LiteDB using default database path:
services.AddSingleton<IApiOutputCache, InMemoryOutputCacheProvider>();
OR define database path implicity
services.AddSingleton<IApiOutputCache, LiteDBOutputCacheProvider>(provider => { return new LiteDBOutputCacheProvider("newFile.db"); });
-
-
In "Startup" class "Configure" method initialize cache output:
app.UseCacheOutput();
-
Decorate any controller method with cache output filters:
[CacheOutput(ClientTimeSpan = 0, ServerTimeSpan = 3600, MustRevalidate = true, ExcludeQueryStringFromCacheKey = false)]
- Read https://github.com/filipw/Strathweb.CacheOutput for more details about common filter usage