SunnyMehr.CacheManager
1.0.0
See the version list below for details.
dotnet add package SunnyMehr.CacheManager --version 1.0.0
NuGet\Install-Package SunnyMehr.CacheManager -Version 1.0.0
<PackageReference Include="SunnyMehr.CacheManager" Version="1.0.0" />
paket add SunnyMehr.CacheManager --version 1.0.0
#r "nuget: SunnyMehr.CacheManager, 1.0.0"
// Install SunnyMehr.CacheManager as a Cake Addin #addin nuget:?package=SunnyMehr.CacheManager&version=1.0.0 // Install SunnyMehr.CacheManager as a Cake Tool #tool nuget:?package=SunnyMehr.CacheManager&version=1.0.0
Add a class library to your solution
Download and install SunnyMehr Cache Manager from link below:
Add ICacheManager interface and CacheManger to class library in order to define customized Add or Get method based on specific Data Model. For example:
public async Task AddTestAsync(string key, string testString) { try { if (_enableLocalCache) _memoryCacheManager.Add(key, testString); if (_enableRedisCache) await _redisManager.AddAsync(key, testString); } catch (Exception exception) { _ = Task.Run(() => _logger.LogError(EventTool.GetEvent(SystemEvent.GlobalCacheManager, "AddTestAsync"), exception, exception.Message)); } }` public async Task<string> GetITestAsync(string key) { try { return (_enableLocalCache ? _memoryCacheManager.Get<string>(key) : null) ?? (_enableRedisCache ? await _redisManager.GetAsync<string>(key) : string.Empty); } catch (Exception exception) { _ = Task.Run(() => _logger.LogError(EventTool.GetEvent(SystemEvent.GlobalRedis, "GetInstrumentAsync"), exception, exception.Message)); return string.Empty; } }`
Add following codes in Program before
builder.Build()
:builder.Services.AddCacheManagerDependencyInjections();
builder.Services.AddSingleton<ICacheManager, CacheManager>();
Add following section to appSettings file:
"DistributedCacheSettings": {
"EnableLocalCache": false,
"EnableDistributedCache": true,
"CacheExpireTotalMinutes": 10,
"RedisConfiguration": {
"AbortOnConnectFail": true,
"MaxValueLength": 0,
"PoolSize": 100,
"KeyPrefix": "",
"ConnectTimeout": 10000,
"SyncTimeout": 20000,
"Database": 0,
"Hosts": [
{
"Host": "172.26.96.2",
"Port": "6379"
}
],
"ServerEnumerationStrategy": {
"Mode": 0, //ALl = 0, Single = 1
"TargetRole": 0, // Any = 0, PreferSlave = 1
"UnreachableServerAction": 0 //Throw =0, IgnoreIfOtherAvailable = 1
},
"ConfigurationOptions": {
"Password": "",
"AbortOnConnectFail": true,
"AllowAdmin": true,
"Ssl": false,
"ConnectTimeout": 10000,
"SyncTimeout": 20000,
"AsyncTimeout": 20000,
"ConnectRetry": 10,
"DefaultDatabase": 0,
"ServiceName": "", // In case you are using Sentinel
"SocketManager": {
"Name": "MySocketManager",
"WorkerCount": 100,
"SocketManagerOptions": 2 //None = 0, UseHighPrioritySocketThreads = 1, UseThreadPool = 2
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 was computed. 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. |
-
net6.0
- Microsoft.Extensions.Caching.Memory (>= 6.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- NuGet.Versioning (>= 6.0.0)
- StackExchange.Redis.Extensions.Core (>= 7.2.1)
- StackExchange.Redis.Extensions.Newtonsoft (>= 7.2.1)
- SunnyMehr.LoggerService (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SunnyMehr.CacheManager:
Package | Downloads |
---|---|
SunnyMehr.HealthMonitor
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 308 | 2/24/2024 |
2.2.4 | 201 | 1/9/2024 |
2.2.3 | 119 | 1/9/2024 |
2.2.2 | 446 | 8/17/2023 |
2.2.1 | 441 | 7/27/2023 |
2.2.0 | 269 | 7/7/2023 |
2.1.9 | 861 | 10/13/2022 |
2.1.8 | 685 | 9/20/2022 |
2.1.7 | 482 | 9/14/2022 |
2.1.6 | 466 | 9/14/2022 |
2.1.5 | 490 | 9/14/2022 |
2.1.4 | 496 | 9/14/2022 |
2.1.3 | 436 | 9/10/2022 |
2.1.2 | 432 | 9/10/2022 |
2.1.1 | 1,229 | 8/2/2022 |
2.1.0 | 579 | 7/26/2022 |
2.0.4 | 474 | 7/16/2022 |
2.0.3 | 460 | 7/16/2022 |
2.0.2 | 432 | 7/16/2022 |
2.0.1 | 436 | 7/16/2022 |
2.0.0 | 1,102 | 1/23/2022 |
1.0.1 | 605 | 1/23/2022 |
1.0.0 | 292 | 12/28/2021 |