NetPro.RedisManager
6.0.3-beta.3
This is a prerelease version of NetPro.RedisManager.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package NetPro.RedisManager --version 6.0.3-beta.3
NuGet\Install-Package NetPro.RedisManager -Version 6.0.3-beta.3
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.3-beta.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.RedisManager --version 6.0.3-beta.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetPro.RedisManager, 6.0.3-beta.3"
#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.3-beta.3&prerelease // Install NetPro.RedisManager as a Cake Tool #tool nuget:?package=NetPro.RedisManager&version=6.0.3-beta.3&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | 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 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.
-
.NETStandard 2.1
- CSRedisCore (>= 3.6.8)
- Microsoft.Extensions.Caching.Memory (>= 6.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- RedLock.net (>= 2.3.1)
- StackExchange.Redis (>= 2.2.88)
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 | 200 | 7/24/2023 |
6.0.15 | 414 | 7/19/2022 |
6.0.14 | 426 | 7/10/2022 |
6.0.13 | 402 | 6/15/2022 |
6.0.12 | 411 | 6/15/2022 |
6.0.11 | 409 | 6/15/2022 |
6.0.10 | 418 | 6/11/2022 |
6.0.9 | 407 | 6/8/2022 |
6.0.8 | 420 | 5/26/2022 |
6.0.8-beta.3 | 124 | 5/24/2022 |
6.0.8-beta.2 | 123 | 5/24/2022 |
6.0.7 | 447 | 5/18/2022 |
6.0.6 | 436 | 4/28/2022 |
6.0.5 | 416 | 3/30/2022 |
6.0.5-beta.20 | 115 | 4/27/2022 |
6.0.5-beta.19 | 125 | 4/25/2022 |
6.0.5-beta.18 | 117 | 4/22/2022 |
6.0.5-beta.17 | 124 | 4/16/2022 |
6.0.5-beta.16 | 138 | 4/8/2022 |
6.0.5-beta.15 | 127 | 4/8/2022 |
6.0.5-beta.14 | 131 | 4/7/2022 |
6.0.5-beta.13 | 137 | 4/7/2022 |
6.0.5-beta.12 | 126 | 4/6/2022 |
6.0.5-beta.11 | 135 | 4/6/2022 |
6.0.5-beta.10 | 132 | 3/31/2022 |
6.0.5-beta.9 | 138 | 3/26/2022 |
6.0.5-beta.8 | 132 | 3/22/2022 |
6.0.5-beta.7 | 125 | 3/21/2022 |
6.0.5-beta.6 | 122 | 3/14/2022 |
6.0.5-beta.5 | 126 | 3/2/2022 |
6.0.5-beta.4 | 127 | 2/22/2022 |
6.0.5-beta.3 | 139 | 2/18/2022 |
6.0.5-beta.2 | 130 | 2/18/2022 |
6.0.5-beta.1 | 129 | 2/16/2022 |
6.0.4 | 475 | 2/10/2022 |
6.0.3 | 459 | 2/9/2022 |
6.0.3-beta.9 | 130 | 2/10/2022 |
6.0.3-beta.7 | 141 | 1/27/2022 |
6.0.3-beta.6 | 139 | 1/19/2022 |
6.0.3-beta.5 | 143 | 1/17/2022 |
6.0.3-beta.4 | 147 | 1/16/2022 |
6.0.3-beta.3 | 133 | 1/14/2022 |
6.0.3-beta.2 | 142 | 1/13/2022 |
6.0.3-beta.1 | 161 | 1/11/2022 |
6.0.2 | 322 | 1/6/2022 |
6.0.1 | 930 | 12/3/2021 |
3.1.11 | 337 | 11/19/2021 |
3.1.10 | 441 | 7/29/2021 |
3.1.9 | 368 | 7/1/2021 |
3.1.8 | 1,756 | 12/15/2020 |
3.1.6 | 1,894 | 9/16/2020 |
3.1.5 | 1,672 | 9/8/2020 |
3.1.3 | 1,802 | 6/30/2020 |
3.1.2 | 1,809 | 6/23/2020 |
3.1.1 | 1,923 | 5/26/2020 |
3.1.0 | 3,005 | 5/24/2020 |
1.0.1 | 2,008 | 5/4/2020 |
1.0.0 | 1,786 | 4/27/2020 |