NetPro.RedisManager 6.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetPro.RedisManager --version 6.0.4                
NuGet\Install-Package NetPro.RedisManager -Version 6.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPro.RedisManager" Version="6.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.RedisManager --version 6.0.4                
#r "nuget: NetPro.RedisManager, 6.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetPro.RedisManager as a Cake Addin
#addin nuget:?package=NetPro.RedisManager&version=6.0.4

// Install NetPro.RedisManager as a Cake Tool
#tool nuget:?package=NetPro.RedisManager&version=6.0.4                

RedisManager使用

同时支持StackExchangeRedis和CsRedis,支持分布式锁 不推荐使用此库,Redis请使用指定客户端实现的 NetPro.CsRedis、NetPro.StackExchange.Redis或者原生CsRedis

appsetting.json


"RedisCacheOption": {
   "Enabled": true,//是否开启
   "RedisComponent": -1,//-1:NullRedis;1:CSRedis;2:StackExchangeRedis
   "Password": "netpro",
   "IsSsl": false,
   "Preheat": 20,//预热
   "Cluster": true, //集群模式
   "ConnectionTimeout": 20,
   "Endpoints": [
   	{
   	 "Port": 6665,
   	 "Host": "192.168.66.33"
   	},
   	{
   	 "Port": 6666,
   	 "Host": "192.168.66.66"
   	}
   ],
   "Database": 0,
   "DefaultCustomKey": "",
   "PoolSize": 50
},

使用

启用redis服务
//新增redis缓存注入
if (configuration.GetValue<bool>("RedisCacheOption:Enabled",false))//是否开启redis
    services.AddRedisManager(configuration);
构造函数注入
public class WeatherForecastController : ControllerBase
{
        private readonly IRedisManager _redisManager;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="redisManager"></param>
        public WeatherForecastController(
            IRedisManager redisManager)
        {
            _redisManager = redisManager;
        }
}

方法说明
/// <summary>
/// 获取缓存,没有则新增缓存
/// 不过期或者过期时间时间大于一小时,数据将缓存到本地内存
/// 过期时间等于-1(永不过期)的缓存无法覆盖更新,建议删除后新增
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key">缓存健值,建议key最少三段以:分割便于的管理</param>
/// <param name="func">缓存不存在要执行的委托</param>
/// <param name="expiredTime">过期时间,单位秒</param>
/// <returns></returns>
T GetOrCreate<T>(string key, Func<T> func = null, int expiredTime -1);
方法中调用

//同步方法
 var result = _redisManager.GetOrCreate<string>("1",func: ()=>//获取key的值,没有找到则执行委托并将委托返回的值插入redis缓存
 {
     return "1";
 },500);


//异步方法
  var resultAsync = await _redisManager.GetOrCreateAsync<string>("1",func: ()=>//获取key的值,没有找到则执行委托并将委托返回的值插入redis缓存
 {
     return "1";
 });
Product 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 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.16 199 7/24/2023
6.0.15 413 7/19/2022
6.0.14 425 7/10/2022
6.0.13 401 6/15/2022
6.0.12 410 6/15/2022
6.0.11 408 6/15/2022
6.0.10 417 6/11/2022
6.0.9 406 6/8/2022
6.0.8 419 5/26/2022
6.0.8-beta.3 123 5/24/2022
6.0.8-beta.2 122 5/24/2022
6.0.7 446 5/18/2022
6.0.6 435 4/28/2022
6.0.5 415 3/30/2022
6.0.5-beta.20 114 4/27/2022
6.0.5-beta.19 124 4/25/2022
6.0.5-beta.18 116 4/22/2022
6.0.5-beta.17 123 4/16/2022
6.0.5-beta.16 137 4/8/2022
6.0.5-beta.15 126 4/8/2022
6.0.5-beta.14 130 4/7/2022
6.0.5-beta.13 136 4/7/2022
6.0.5-beta.12 125 4/6/2022
6.0.5-beta.11 134 4/6/2022
6.0.5-beta.10 131 3/31/2022
6.0.5-beta.9 137 3/26/2022
6.0.5-beta.8 131 3/22/2022
6.0.5-beta.7 124 3/21/2022
6.0.5-beta.6 121 3/14/2022
6.0.5-beta.5 123 3/2/2022
6.0.5-beta.4 126 2/22/2022
6.0.5-beta.3 138 2/18/2022
6.0.5-beta.2 129 2/18/2022
6.0.5-beta.1 128 2/16/2022
6.0.4 474 2/10/2022
6.0.3 458 2/9/2022
6.0.3-beta.9 129 2/10/2022
6.0.3-beta.7 140 1/27/2022
6.0.3-beta.6 138 1/19/2022
6.0.3-beta.5 142 1/17/2022
6.0.3-beta.4 146 1/16/2022
6.0.3-beta.3 132 1/14/2022
6.0.3-beta.2 141 1/13/2022
6.0.3-beta.1 160 1/11/2022
6.0.2 321 1/6/2022
6.0.1 929 12/3/2021
3.1.11 336 11/19/2021
3.1.10 440 7/29/2021
3.1.9 367 7/1/2021
3.1.8 1,755 12/15/2020
3.1.6 1,893 9/16/2020
3.1.5 1,671 9/8/2020
3.1.3 1,801 6/30/2020
3.1.2 1,808 6/23/2020
3.1.1 1,922 5/26/2020
3.1.0 3,004 5/24/2020
1.0.1 2,007 5/4/2020
1.0.0 1,785 4/27/2020