EasyMultiCacheManager.Api
2.0.0
See the version list below for details.
dotnet add package EasyMultiCacheManager.Api --version 2.0.0
NuGet\Install-Package EasyMultiCacheManager.Api -Version 2.0.0
<PackageReference Include="EasyMultiCacheManager.Api" Version="2.0.0" />
paket add EasyMultiCacheManager.Api --version 2.0.0
#r "nuget: EasyMultiCacheManager.Api, 2.0.0"
// Install EasyMultiCacheManager.Api as a Cake Addin #addin nuget:?package=EasyMultiCacheManager.Api&version=2.0.0 // Install EasyMultiCacheManager.Api as a Cake Tool #tool nuget:?package=EasyMultiCacheManager.Api&version=2.0.0
Manage Cache Easily
Usage
First install package:
If you want Redis then install:
If you want Database then install:
https://www.nuget.org/packages/EasyMultiCacheManager.Database
If you want Api then install:
Then you can use like this:
var easyCacheManager = new CacheBuilder()
.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<string>("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, 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
Contributors
The following contributors have made this project better:
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
- EasyMultiCacheManager (>= 2.0.0)
- Flurl.Http (>= 4.0.2)
-
.NETStandard 2.0
- EasyMultiCacheManager (>= 2.0.0)
- Flurl.Http (>= 4.0.2)
-
net8.0
- EasyMultiCacheManager (>= 2.0.0)
- Flurl.Http (>= 4.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
CacheManager.Api