Aore.Redis 1.0.0

dotnet add package Aore.Redis --version 1.0.0
                    
NuGet\Install-Package Aore.Redis -Version 1.0.0
                    
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="Aore.Redis" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aore.Redis" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Aore.Redis" />
                    
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 Aore.Redis --version 1.0.0
                    
#r "nuget: Aore.Redis, 1.0.0"
                    
#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 Aore.Redis@1.0.0
                    
#: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=Aore.Redis&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Aore.Redis&version=1.0.0
                    
Install as a Cake Tool

Aore.Redis — .NET SDK

Static Badge license

[English Version]

📈 一个基于 .netstandard2.0与StackExchange.Redis实现的操作Redis数据库开发组件,助力大量系统和应用取得成功。我将继续保持更新,并正在深度融合更多场景应用👐

使用 Aore.Redis,您可以方便快速将现有项目或新项目实现操作Redis数据库。

目前 Aore.Redis 支持 .NET Standard 2.0 等多种框架,同时兼容所有 MVC、Razor、WebApi、Console(命令行)、桌面应用(.exe)和后台服务等环境,和外部框架完全解耦。

希望有更多的人可以从中受益,理解并传播开源的精神,一同助力中国开源事业!感恩一路上给我们提供帮助的朋友们!

如果你喜欢并希望我们继续优化这个项目,请给我们一个 ★Star :)

✨ 功能特性

  • 支持 Redis 字符串操作
  • 支持 Redis 哈希操作
  • 支持 Redis 列表操作
  • 支持 Redis 有序集合操作
  • 支持 Redis 键操作
  • 支持 Redis 发布/订阅模式
  • Aore.Redis 支持Redis,同时也支持 Microsoft的Garnet

🚀 Redis 操作示例 :开启你的改造开发之旅!

.NET CLI:
dotnet add package Aore.Redis --version 1.0.0

或

Nuget包进行搜索下载

🛠 初始化 RedisHelper

using (var redisHelper = new RedisHelper("localhost:6379", "Aore.Redis")) 
{ 
  // 执行 Redis 操作
}

🔍 字符串操作

using (var redisHelper = new RedisHelper("localhost:6379", "Aore.Redis")) 
{ 
  // 设置字符串值 
  var setResult = redisHelper.StringSet("Main:Name", "Hello World");
  
  // 获取字符串值
  var value = redisHelper.StringGet<string>("Main:Name");
  
  // 异步设置字符串值
  var setResultAsync = await redisHelper.StringSetAsync("TestKeyAsync", "TestValueAsync");
  
  // 异步获取字符串值
  string getResult = await redisHelper.StringGetAsync("TestKeyAsync", null);
  
  // 存储对象(自动序列化)
  var obj = new StudentEntiy() { Name = "John", Age = 30 };
  bool setObjectResult = redisHelper.StringSet("TestObjectKey", obj);
  
  // 获取对象(自动反序列化)
  var resultObj = redisHelper.StringGet<StudentEntiy>("TestObjectKey");
}

// ...

☑️ 哈希操作

using (var redisHelper = new RedisHelper("localhost:6379", "Aore.Redis")) 
{ 
  string key = "TestHashKey"; 
  string field = "TestField"; 
  string value = "TestValue";
  
  // 设置哈希字段
  bool setResult = redisHelper.HashSet(key, field, value);
  
  // 获取哈希字段
  RedisValue getResult = redisHelper.HashGet(key, field);
}

// ...

➕ 列表操作

using (var redisHelper = new RedisHelper("localhost:6379", "Aore.Redis")) 
{ 
  string key = "TestListKey"; 
  string value = "TestListItem";
  
  // 右侧推入
  long pushResult = redisHelper.ListRightPush(key, value);
  
  // 左侧弹出
  string popResult = redisHelper.ListLeftPop(key);
}

// ...

🪧 有序集合操作

using (var redisHelper = new RedisHelper("localhost:6379", "Aore.Redis")) 
{ 
  string key = "TestSortedSetKey"; 
  string member = "Member1"; 
  double score = 10;
  
  // 添加成员
  bool addResult = redisHelper.SortedSetAdd(key, member, score);
  
  // 获取长度
  long length = redisHelper.SortedSetLength(key);
  
  // 删除成员
  bool removeResult = redisHelper.SortedSetRemove(key, member);
}

// ...

📚 键操作

using (var redisHelper = new RedisHelper("localhost:6379", "Aore.Redis")) 
{ 
  string key = "TestKeyForDelete";
  
  // 设置一个键
  redisHelper.StringSet(key, "value");
  
  // 检查是否存在
  bool exists = redisHelper.KeyExists(key);
  
  // 删除键
  bool deleteResult = redisHelper.KeyDelete(key);
}

// ...

📚 发布/订阅操作

using (var redisHelper = new RedisHelper("localhost:6379", "Common.Redis", 1)) 
{ 
  RedisChannel channel = "TestChannel"; 
  string message = "Hello Redis Pub/Sub"; 
  bool received = false;
  
  // 订阅消息
  redisHelper.Subscribe(channel, (ch, msg) =>
  {
      Assert.AreEqual(message, msg.ToString());
      received = true;
  });
  
  // 发布消息
  long count = redisHelper.Publish(channel, message);
}

// ...

✋ 贡献代码

如果需要使用或修改此项目的源代码,建议先Fork。也欢迎将您修改的通用版本Pull Request过来。

  1. Fork
  2. 创建您的特性分支 (git checkout -b my-new-feature)
  3. 提交您的改动 (git commit -am 'Added some feature')
  4. 将您的修改记录提交到远程 git 仓库 (git push origin my-new-feature)
  5. 然后到 github 网站的该 git 远程仓库的 my-new-feature 分支下发起 Pull Request (请提交到 Developer 分支,不要直接提交到 master 分支)
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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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.0.0 467 7/25/2025

Aore.Redis 支持Redis,同时也支持 Microsoft的Garnet