Skip to content

5. Cache storages

Vladyslav Lobyntsev edited this page Mar 5, 2024 · 3 revisions

Currently, in-memory and distributed cache storages are supported.

1. In-memory storage

In-memory cache storage is represented by MemoryCacheImplementation class. It uses the default System.Runtime.Caching.MemoryCache under the hood. It is available as VLobyntsev.FluentCaching.Memory Nuget package. The package exposes 2 extension methods StoreInMemory and SetInMemoryAsDefaultCache to configure in-memory cache per entity or globally. The source code can be found here.

2. Distributed storage

Distributed cache storage is represented by DistributedCacheImplementation class. It uses the default Microsoft.Extensions.Caching.Distributed.IDistributedCache under the hood, so distributed caches other than Redis can be used. By default, it stores data in JSON format, using System.Text.Json, but this can be customized (see Customizations page). It is available as VLobyntsev.FluentCaching.DistributedCache Nuget package. The package exposes 3 extension methods StoreInDistributedCache and SetDistributedAsDefaultCache to configure distributed cache per entity or globally. Also UseFluentCaching for ASP.NET Core applications, when IDistributedCache instance should be resolved from ASP.NET Core DI Container. The source code can be found here.

Clone this wiki locally