NetPro.RedisManager 6.0.16

dotnet add package NetPro.RedisManager --version 6.0.16
NuGet\Install-Package NetPro.RedisManager -Version 6.0.16
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.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.RedisManager --version 6.0.16
#r "nuget: NetPro.RedisManager, 6.0.16"
#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.16

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

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 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. 
.NET Core netcoreapp3.1 is compatible. 
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 160 7/24/2023
6.0.15 391 7/19/2022
6.0.14 407 7/10/2022
6.0.13 379 6/15/2022
6.0.12 398 6/15/2022
6.0.11 391 6/15/2022
6.0.10 392 6/11/2022
6.0.9 385 6/8/2022
6.0.8 403 5/26/2022
6.0.8-beta.3 106 5/24/2022
6.0.8-beta.2 105 5/24/2022
6.0.7 425 5/18/2022
6.0.6 404 4/28/2022
6.0.5 405 3/30/2022
6.0.5-beta.20 105 4/27/2022
6.0.5-beta.19 113 4/25/2022
6.0.5-beta.18 105 4/22/2022
6.0.5-beta.17 113 4/16/2022
6.0.5-beta.16 120 4/8/2022
6.0.5-beta.15 116 4/8/2022
6.0.5-beta.14 120 4/7/2022
6.0.5-beta.13 119 4/7/2022
6.0.5-beta.12 115 4/6/2022
6.0.5-beta.11 118 4/6/2022
6.0.5-beta.10 114 3/31/2022
6.0.5-beta.9 122 3/26/2022
6.0.5-beta.8 115 3/22/2022
6.0.5-beta.7 106 3/21/2022
6.0.5-beta.6 112 3/14/2022
6.0.5-beta.5 110 3/2/2022
6.0.5-beta.4 117 2/22/2022
6.0.5-beta.3 123 2/18/2022
6.0.5-beta.2 120 2/18/2022
6.0.5-beta.1 119 2/16/2022
6.0.4 443 2/10/2022
6.0.3 438 2/9/2022
6.0.3-beta.9 114 2/10/2022
6.0.3-beta.7 130 1/27/2022
6.0.3-beta.6 123 1/19/2022
6.0.3-beta.5 128 1/17/2022
6.0.3-beta.4 129 1/16/2022
6.0.3-beta.3 123 1/14/2022
6.0.3-beta.2 127 1/13/2022
6.0.3-beta.1 151 1/11/2022
6.0.2 291 1/6/2022
6.0.1 902 12/3/2021
3.1.11 310 11/19/2021
3.1.10 409 7/29/2021
3.1.9 342 7/1/2021
3.1.8 1,698 12/15/2020
3.1.6 1,845 9/16/2020
3.1.5 1,620 9/8/2020
3.1.3 1,743 6/30/2020
3.1.2 1,770 6/23/2020
3.1.1 1,867 5/26/2020
3.1.0 2,943 5/24/2020
1.0.1 1,949 5/4/2020
1.0.0 1,752 4/27/2020