NetPro.CsRedis
6.0.3-beta.2
This is a prerelease version of NetPro.CsRedis.
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.CsRedis --version 6.0.3-beta.2
NuGet\Install-Package NetPro.CsRedis -Version 6.0.3-beta.2
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.CsRedis" Version="6.0.3-beta.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.CsRedis --version 6.0.3-beta.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetPro.CsRedis, 6.0.3-beta.2"
#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.CsRedis as a Cake Addin #addin nuget:?package=NetPro.CsRedis&version=6.0.3-beta.2&prerelease // Install NetPro.CsRedis as a Cake Tool #tool nuget:?package=NetPro.CsRedis&version=6.0.3-beta.2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RedisManager使用
支持CsRedis,支持分布式锁
appsetting.json
"RedisCacheOption": {
"Enabled": true,
"ConnectionString": [
{
"Key": "1", //连接串key别名,唯一,用来物理隔离
"Value": "127.0.0.1:6379,password=123,defaultDatabase=0,poolsize=10,preheat=20,ssl=false,writeBuffer=10240,prefix=key前辍,testcluster=false,idleTimeout=10" //别名key对应的连接串
}
]
}
使用
启用redis服务
public void ConfigureServices(IServiceCollection services)
{
//新增redis缓存注入
services.AddCsRedis<NetPro.CsRedis.SystemTextJsonSerializer>(Configuration);
}
构造函数注入
public class WeatherForecastController : ControllerBase
{
private readonly IRedisManager _redisManager;
/// <summary>
///
/// </summary>
/// <param name="redisManager"></param>
public WeatherForecastController(
IRedisManager redisManager)
{
_redisManager = redisManager;
}
}
方法说明
/// <summary>
///获取或者创建缓存
/// localExpiredTime参数大于0并且小于expiredTime数据将缓存到本地内存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="func"></param>
/// <param name="expiredTime">redis过期时间,默认不过期</param>
/// <param name="localExpiredTime">本地过期时间,0 默认本地不缓存单位秒</param>
/// <returns></returns>
T GetOrSet<T>(string key, Func<T> func = null, TimeSpan? expiredTime = null, int localExpiredTime = 0);
方法中调用
//同步方法
var result = _redisManager.GetOrCreate<string>("1",func: ()=>//获取key的值,没有找到则执行委托并将委托返回的值插入redis缓存
{
return "1";
},TimeSpan.FromeSecond(66));
//异步方法
var resultAsync = await _redisManager.GetOrCreateAsync<string>("1",func: async()=>//获取key的值,没有找到则执行委托并将委托返回的值插入redis缓存
{
return await Task.FromResult("1") ;
});
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- CSRedisCore (>= 3.6.8)
- IdleBus (>= 1.5.2)
- NetPro.Core (>= 6.0.3-beta.2)
- Newtonsoft.Json (>= 12.0.3)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on NetPro.CsRedis:
Package | Downloads |
---|---|
NetPro.ResponseCache
Package Description |
|
NetPro.Analysic
Request analysis component, analysis of requests with custom policies, fusing, etc. |
|
NetPro.Analysicn
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on NetPro.CsRedis:
Repository | Stars |
---|---|
LeonKou/NetPro
🌈An enhanced version with clean architecture of asp.netcore,efficiently manage startup,Support for netcore3.1/6.0
|
Version | Downloads | Last updated |
---|---|---|
6.0.16 | 347 | 7/24/2023 |
6.0.15 | 850 | 7/19/2022 |
6.0.14 | 884 | 7/10/2022 |
6.0.13 | 866 | 6/15/2022 |
6.0.12 | 881 | 6/15/2022 |
6.0.11 | 857 | 6/15/2022 |
6.0.10 | 882 | 6/11/2022 |
6.0.9 | 885 | 6/8/2022 |
6.0.8 | 915 | 5/26/2022 |
6.0.8-beta.3 | 143 | 5/24/2022 |
6.0.8-beta.2 | 118 | 5/24/2022 |
6.0.7 | 888 | 5/18/2022 |
6.0.6 | 885 | 4/28/2022 |
6.0.5 | 852 | 3/30/2022 |
6.0.5-beta.20 | 123 | 4/27/2022 |
6.0.5-beta.19 | 132 | 4/25/2022 |
6.0.5-beta.18 | 119 | 4/22/2022 |
6.0.5-beta.17 | 125 | 4/16/2022 |
6.0.5-beta.16 | 584 | 4/8/2022 |
6.0.5-beta.15 | 137 | 4/8/2022 |
6.0.5-beta.14 | 133 | 4/7/2022 |
6.0.5-beta.13 | 130 | 4/7/2022 |
6.0.5-beta.12 | 122 | 4/6/2022 |
6.0.5-beta.11 | 154 | 4/6/2022 |
6.0.5-beta.10 | 143 | 3/31/2022 |
6.0.5-beta.9 | 148 | 3/26/2022 |
6.0.5-beta.8 | 158 | 3/22/2022 |
6.0.5-beta.7 | 138 | 3/21/2022 |
6.0.5-beta.6 | 148 | 3/14/2022 |
6.0.5-beta.5 | 147 | 3/2/2022 |
6.0.5-beta.4 | 146 | 2/22/2022 |
6.0.5-beta.3 | 145 | 2/18/2022 |
6.0.5-beta.2 | 125 | 2/18/2022 |
6.0.5-beta.1 | 141 | 2/16/2022 |
6.0.4 | 727 | 2/10/2022 |
6.0.3 | 709 | 2/9/2022 |
6.0.3-beta.9 | 131 | 2/10/2022 |
6.0.3-beta.7 | 153 | 1/27/2022 |
6.0.3-beta.6 | 148 | 1/19/2022 |
6.0.3-beta.5 | 139 | 1/17/2022 |
6.0.3-beta.4 | 144 | 1/16/2022 |
6.0.3-beta.3 | 145 | 1/14/2022 |
6.0.3-beta.2 | 142 | 1/13/2022 |
6.0.3-beta.1 | 167 | 1/11/2022 |
6.0.2 | 452 | 1/6/2022 |
6.0.1 | 1,177 | 12/3/2021 |
3.1.11 | 636 | 11/17/2021 |
3.1.10 | 1,978 | 7/29/2021 |
3.1.9 | 2,404 | 7/1/2021 |
3.1.8 | 416 | 12/15/2020 |