NewLife.Redis.Core 1.9.2023.1211

dotnet add package NewLife.Redis.Core --version 1.9.2023.1211                
NuGet\Install-Package NewLife.Redis.Core -Version 1.9.2023.1211                
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="NewLife.Redis.Core" Version="1.9.2023.1211" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NewLife.Redis.Core --version 1.9.2023.1211                
#r "nuget: NewLife.Redis.Core, 1.9.2023.1211"                
#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 NewLife.Redis.Core as a Cake Addin
#addin nuget:?package=NewLife.Redis.Core&version=1.9.2023.1211

// Install NewLife.Redis.Core as a Cake Tool
#tool nuget:?package=NewLife.Redis.Core&version=1.9.2023.1211                

<h1>一、项目说明</h1> <p>NewLife.Redis.Core基于新生命团队NewLife.Redis的封装,支持.NETCore3/.NET6/7。</p> <p dir="auto"><span style="color: #e03e2d;">NewLife.Redis</span> 是一个Redis客户端组件,以高性能处理大数据实时计算为目标。</p> <p dir="auto">源码: <a href="https://github.com/NewLifeX/NewLife.Redis">https://github.com/NewLifeX/NewLife.Redis</a><br />Nuget:NewLife.Redis<br />教程:<a href="https://newlifex.com/core/redis" rel="nofollow">https://newlifex.com/core/redis</a></p> <h1>二、使用说明</h1> <h2>2.1 通过New的方式安装使用</h2> <h3>2.1.1 单客户端模式</h3> <pre class="language-csharp highlighter-hljs"><code>using NewLife.Redis.Core; NewLifeRedis redis = new NewLifeRedis("server=127.0.0.1:6379;password=Shiny123456;db=4"); //普通操作 redis.Set("test", "1"); Console.WriteLine(redis.Get<string>("test")); //列表 redis.ListAdd("listtest", 1); redis.ListGetAll<string>("listtest"); //SortedSet redis.SortedSetAdd("sortsettest", "1", 1.0); redis.SortedSetIncrement("sortsettest", "1", 1.0); //set redis.SetAdd("settest", "2"); //哈希 redis.HashAdd("hashtest", "1", "2"); redis.HashGet<string>("hashtest", new string[] { "1" }); //队列操作 //方式1 var queue = redis.GetRedisQueue<string>("queue"); queue.Add("test"); var data = queue.Take(1); //方式2 redis.AddQueue("queue", "1"); redis.GetQueueOne<string>("queue");</code></pre> <h3>2.1.2 多客户端模式</h3> <pre class="language-csharp highlighter-hljs"><code>var redisCacheManager = new RedisCacheManager(new List<RedisConfig> { new RedisConfig { Name = "1", ConnectionString = "xxx" } }); redisCacheManager.AddRedis(new RedisConfig { Name = "2", ConnectionString = "xx" }); //支持动态添加和删除 redisCacheManager.AddRedis(new RedisConfig { Name = "test", ConnectionString = "xx" }); redisCacheManager.RemoveRedis("test"); var redis = redisCacheManager.GetRedis("2"); //普通操作 redis.Set("test", "1"); Console.WriteLine(redis.Get<string>("test")); //列表 redis.ListAdd("listtest", 1); redis.ListGetAll<string>("listtest"); //SortedSet redis.SortedSetAdd("sortsettest", "1", 1.0); redis.SortedSetIncrement("sortsettest", "1", 1.0); //set redis.SetAdd("settest", "2"); //哈希 redis.HashAdd("hashtest", "1", "2"); redis.HashGet<string>("hashtest", new string[] { "1" }); //队列操作 //方式1 var queue = redis.GetRedisQueue<string>("queue"); queue.Add("test"); var data = queue.Take(1); //方式2 redis.AddQueue("queue", "1"); redis.GetQueueOne<string>("queue");</code></pre> <h2>2.2 通过IOC注入(推荐)</h2> <h3>2.2.1 单客户端注入</h3> <p>ConfigureServices里注册组件</p> <pre class="language-csharp highlighter-hljs"><code>//默认读取配置文件:ConnectionStrings:Redis services.AddNewLifeRedis(); //指定链接字符串 services.AddNewLifeRedis("server=127.0.0.1:6379;password=xxx;db=4");</code></pre> <p>构造函数里注入INewLifeRedis</p> <pre class="language-csharp highlighter-hljs"><code>private readonly INewLifeRedis newLifeRedis; public Worker(ILogger<Worker> logger, INewLifeRedis newLifeRedis) { _logger = logger; this.newLifeRedis = newLifeRedis; newLifeRedis.Set("test", "2"); }</code></pre> <h3>2.2.2 多客户端注入</h3> <p>配置文件不能再是字符串格式而要改成下面格式</p> <pre class="language-csharp highlighter-hljs"><code>"ConnectionStrings": { "Redis": [ { "Name": "1", "ConnectionString": "server=127.0.0.1:6379;password=123456;db=4" }, { "Name": "2", "ConnectionString": "server=127.0.0.1:6379;password=123456;db=5" } ] },</code></pre> <p>ConfigureServices里注册组件</p> <pre class="language-csharp highlighter-hljs"><code>services.AddRedisCacheManager(); services.AddRedisCacheManager(hostContext.Configuration, "xxx");//第二种</code></pre> <p>构造函数里注入IRedisCacheManager</p> <pre class="language-csharp highlighter-hljs"><code>private readonly ISimpleRedis newLifeRedis; public Worker(ILogger<Worker> logger, IRedisCacheManager redisCacheManager) { _logger = logger; newLifeRedis = redisCacheManager.GetRedis("1"); newLifeRedis.Set("TEST", "test"); newLifeRedis = redisCacheManager.GetRedis("2"); newLifeRedis.Set("TEST", "test"); //支持动态添加和删除 redisCacheManager.AddRedis(new RedisConfig { Name = "test", ConnectionString = "xx" }); redisCacheManager.RemoveRedis("test"); }</code></pre> <h1>三、实现消息队列</h1> <p><span style="font-size: 24px;">详情可以看我的这篇文章:<a href="https://www.cnblogs.com/huguodong/p/16434717.html" target="_blank" rel="noopener">.Net大杀器之基于Newlife.Redis的可重复消费+共享订阅队列来替换第三方MQ</a></span></p> <h1>四、源码地址</h1> <p><span style="font-size: 24px;">Github:<a href="https://github.com/NewLifeX/NewLife.Redis.Core" target="_blank" rel="noopener">https://github.com/NewLifeX/NewLife.Redis.Core</a></span></p> <p><span style="font-size: 24px;">Gitee:<a href="https://gitee.com/huguodong520/NewLife.Redis.Core.git" target="_blank" rel="noopener">https://gitee.com/huguodong520/NewLife.Redis.Core.git</a></span></p>

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 is compatible.  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 is compatible.  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
1.9.2023.1211 2,159 12/11/2023
1.9.2023.1205 170 12/5/2023
1.8.2023.918 505 9/18/2023
1.8.2023.830 237 9/8/2023
1.8.2023.421 2,552 4/21/2023
1.7.2022.1220 3,149 12/20/2022
1.6.2022.1219 336 12/19/2022
1.5.2022.1214 397 12/14/2022
1.4.2022.1213 322 12/13/2022
1.3.2022.1213 304 12/13/2022
1.2.2022.1115 504 11/15/2022
1.2.2022.1111 378 11/11/2022
1.2.2022.1018 475 10/18/2022
1.2.2022.901 589 9/1/2022
1.2.2022.822 420 8/22/2022
1.2.2022.720 736 7/20/2022
1.1.2022.720 443 7/20/2022