NewLife.Redis.Core 1.9.2023.1211

There is a newer prerelease version of this package available.
See the version list below for details.
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.
<PackageVersion Include="NewLife.Redis.Core" Version="1.9.2023.1211" />
                    
Directory.Packages.props
<PackageReference Include="NewLife.Redis.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package NewLife.Redis.Core@1.9.2023.1211
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NewLife.Redis.Core&version=1.9.2023.1211
                    
Install as a Cake Addin
#tool nuget:?package=NewLife.Redis.Core&version=1.9.2023.1211
                    
Install as a Cake Tool

<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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (1)

Showing the top 1 popular GitHub repositories that depend on NewLife.Redis.Core:

Repository Stars
dorisoy/Dorisoy.Pan
Dorisoy.Pan 是基于.net core8 的跨平台文档管理系统,使用 MS SQL 2012 / MySql8.0(或更高版本)后端数据库,您可以在 Windows、Linux 或 Mac 上运行它,项目中的所有方法都是异步的,支持令牌基身份验证,项目体系结构遵循著名的软件模式和最佳安全实践。源代码是完全可定制的,热插拔且清晰的体系结构,使开发定制功能和遵循任何业务需求变得容易。 系统使用最新的 Microsoft 技术,高性能稳定性和安全性
Version Downloads Last Updated
2.0.2025.516-beta0631 214 5/16/2025
1.9.2023.1211 5,578 12/11/2023
1.9.2023.1205 195 12/5/2023
1.8.2023.918 570 9/18/2023
1.8.2023.830 279 9/8/2023
1.8.2023.421 3,054 4/21/2023
1.7.2022.1220 3,374 12/20/2022
1.6.2022.1219 401 12/19/2022
1.5.2022.1214 462 12/14/2022
1.4.2022.1213 384 12/13/2022
1.3.2022.1213 364 12/13/2022
1.2.2022.1115 586 11/15/2022
1.2.2022.1111 438 11/11/2022
1.2.2022.1018 556 10/18/2022
1.2.2022.901 660 9/1/2022
1.2.2022.822 489 8/22/2022
1.2.2022.720 805 7/20/2022
1.1.2022.720 521 7/20/2022