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 207 7/24/2023
6.0.15 420 7/19/2022
6.0.14 432 7/10/2022
6.0.13 408 6/15/2022
6.0.12 417 6/15/2022
6.0.11 415 6/15/2022
6.0.10 424 6/11/2022
6.0.9 413 6/8/2022
6.0.8 426 5/26/2022
6.0.8-beta.3 126 5/24/2022
6.0.8-beta.2 125 5/24/2022
6.0.7 453 5/18/2022
6.0.6 442 4/28/2022
6.0.5 422 3/30/2022
6.0.5-beta.20 117 4/27/2022
6.0.5-beta.19 127 4/25/2022
6.0.5-beta.18 119 4/22/2022
6.0.5-beta.17 126 4/16/2022
6.0.5-beta.16 140 4/8/2022
6.0.5-beta.15 129 4/8/2022
6.0.5-beta.14 133 4/7/2022
6.0.5-beta.13 139 4/7/2022
6.0.5-beta.12 128 4/6/2022
6.0.5-beta.11 137 4/6/2022
6.0.5-beta.10 134 3/31/2022
6.0.5-beta.9 140 3/26/2022
6.0.5-beta.8 134 3/22/2022
6.0.5-beta.7 127 3/21/2022
6.0.5-beta.6 124 3/14/2022
6.0.5-beta.5 128 3/2/2022
6.0.5-beta.4 129 2/22/2022
6.0.5-beta.3 141 2/18/2022
6.0.5-beta.2 132 2/18/2022
6.0.5-beta.1 131 2/16/2022
6.0.4 482 2/10/2022
6.0.3 465 2/9/2022
6.0.3-beta.9 132 2/10/2022
6.0.3-beta.7 143 1/27/2022
6.0.3-beta.6 141 1/19/2022
6.0.3-beta.5 145 1/17/2022
6.0.3-beta.4 149 1/16/2022
6.0.3-beta.3 135 1/14/2022
6.0.3-beta.2 144 1/13/2022
6.0.3-beta.1 163 1/11/2022
6.0.2 328 1/6/2022
6.0.1 936 12/3/2021
3.1.11 343 11/19/2021
3.1.10 447 7/29/2021
3.1.9 374 7/1/2021
3.1.8 1,762 12/15/2020
3.1.6 1,900 9/16/2020
3.1.5 1,678 9/8/2020
3.1.3 1,809 6/30/2020
3.1.2 1,815 6/23/2020
3.1.1 1,929 5/26/2020
3.1.0 3,013 5/24/2020
1.0.1 2,014 5/4/2020
1.0.0 1,792 4/27/2020