EasyMultiCacheManager 1.0.4
See the version list below for details.
dotnet add package EasyMultiCacheManager --version 1.0.4
NuGet\Install-Package EasyMultiCacheManager -Version 1.0.4
<PackageReference Include="EasyMultiCacheManager" Version="1.0.4" />
paket add EasyMultiCacheManager --version 1.0.4
#r "nuget: EasyMultiCacheManager, 1.0.4"
// Install EasyMultiCacheManager as a Cake Addin #addin nuget:?package=EasyMultiCacheManager&version=1.0.4 // Install EasyMultiCacheManager as a Cake Tool #tool nuget:?package=EasyMultiCacheManager&version=1.0.4
Manage Cache Easily
Usage
First install package:
then you can use like this:
var easyCacheManager = new CacheBuilder<string>()
.AddApi(new ApiConfig
{
Url = StaticData.Api
})
.AddRedis(new RedisConfig
{
ConnectionString = redisConnectionString
})
.AddDb(new DbConfig
{
ConnectionString = sqlConnectionString,
Query = StaticData.QueryToSelect
})
.AddMemory(new MemoryConfig())
.Build(new LockConfig());
var result = await easyCacheManager.GetAsync("My-Key");
You can create your own provider with these interfaces:
- IBaseCacheSource
- ICacheSourceWithClear
- ICacheSourceWithSet
- ICacheSourceWithSetAndClear
Default providers are these:
- MemoryCacheSource : ICacheSourceWithSetAndClear : Priority ⇒ 1
- RedisCacheSource : ICacheSourceWithSetAndClear : Priority ⇒ 2
- DbCacheSource : IBaseCacheSource : Priority ⇒ 3
- ApiCacheSource : IBaseCacheSource : Priority ⇒ 4
On IBaseCacheSource
you have only Get
from cache, for example on ApiCacheSource
you get real data from api.
if item find from one provider and not exist on other provider, it will automatically set to other providers that implemented from ICacheSourceWithSetAndClear
or ICacheSourceWithSet
Example
First try get from Memory because it Priority
is 1, if not exist it try get from redis, after that it try to get from db, and after that it get data from api. if not found it will return null.
also if found on db or api it will set to redis and memory.
Concurrency
This package use AsyncKeyedLock to handle lock on get, set and clear on specific key. so you use this package on multi thread program.
Info
You can use all type like class, object, string to cache, for example EasyCacheManager<string>, EasyCacheManager<MyClass>
Priority should be unique, you can't crate EasyCacheManager with list of providers with same Priority
Clear cache
With ClearCacheAsync
method you can clear specific key on all providers that implement ICacheSourceWithClear
or ICacheSourceWithSetAndClear
Set
With SetAsync
you can manually set value to provides that that implement ICacheSourceWithSet
or ICacheSourceWithSetAndClear
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- AsyncKeyedLock (>= 7.1.3)
- Dapper (>= 2.1.35)
- Flurl.Http (>= 4.0.2)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- StackExchange.Redis (>= 2.8.16)
-
.NETStandard 2.0
- AsyncKeyedLock (>= 7.1.3)
- Dapper (>= 2.1.35)
- Flurl.Http (>= 4.0.2)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- StackExchange.Redis (>= 2.8.16)
-
net8.0
- AsyncKeyedLock (>= 7.1.3)
- Dapper (>= 2.1.35)
- Flurl.Http (>= 4.0.2)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- StackExchange.Redis (>= 2.8.16)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on EasyMultiCacheManager:
Package | Downloads |
---|---|
EasyMultiCacheManager.Redis
Easy Cache Manager Redis |
|
EasyMultiCacheManager.Database
Easy Cache Manager Database |
|
EasyMultiCacheManager.Api
Easy Cache Manager Api |
|
EasyMultiCacheManager.Clear
Easy Cache Manager Clear |
|
EasyMultiCacheManager.SqlServer
Easy Cache Manager SqlServer Database |
GitHub repositories
This package is not used by any popular GitHub repositories.
CacheManager