Liwendong.CacheExtend.StackExchangeRedis 1.3.1

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

Liwendong.CacheExtend.StackExchangeRedis

基于 StackExchange.Redis 的缓存管理组件,实现 ICacheHelper 接口。

更新日志

1.2.0 (2026-10-15)

  • 新增:目标框架扩展为 net8.0;netcoreapp3.1;net451;net46;net47;net48(新增 net8.0 与 net48)
  • 说明:net8.0 与 netcoreapp3.1 同档使用 StackExchange.Redis 2.8.58(netstandard2.0 资产兼容 net8.0),.NET Framework 侧沿用 1.2.6,无行为变更

1.1.1 (2026-10-09)

  • 修复:连接管理重构,使用全局锁+连接串跟踪,修复多实例锁失效问题
  • 修复:连接串变化时能正确重建连接
  • 修复:RemoveAll Lua脚本unpack栈溢出问题(改为分批删除)
  • 修复:异常类型(ArgumentNullException误用message → ArgumentException)
  • 修复:Set(null)返回值不一致问题
  • 优化:Exists改用KeyExists避免拉取大value
  • 优化:Remove改用批量KeyDelete API
  • 优化:Get<T>反序列化失败返回default(与其他实现一致)
  • 优化:GetKeysByPattern只查询主节点
  • 优化:修正类注释和Description拼写错误

1.1.0

  • 初始版本

功能特性

  • 实现 Liwendong.CacheExtend.ICacheHelper 接口
  • 支持缓存的基本操作:设置、获取、删除、检查存在
  • 支持按模式批量删除缓存
  • 使用 JSON 序列化存储对象
  • 线程安全的连接管理

安装

dotnet add package Liwendong.CacheExtend.StackExchangeRedis

使用示例

using Liwendong.CacheExtend.StackExchangeRedis;

// 创建实例
var cache = new StackExchangeRedisHelper("localhost:6379,abortConnect=false");

// 设置缓存
cache.Set("key", "value");
cache.Set("key", "value", 3600); // 1小时过期

// 获取缓存
var value = cache.Get<string>("key");

// 检查存在
bool exists = cache.Exists("key");

// 删除缓存
cache.Remove("key");
cache.Remove("key1", "key2", "key3");

// 按前缀删除
cache.RemoveByPattern("prefix_*");

注意事项

  • 建议使用连接池或单例模式管理 StackExchangeRedisHelper 实例
  • RemoveAll 会清空整个 Redis 数据库,请谨慎使用

版本历史

1.3.1 (2026-10-20)

  • 优化:RemoveAll 补充共享 Redis 数据库误删警告文档(按 "*" 全量匹配删除当前库所有键,非按应用前缀隔离;多应用共享同一数据库时会误删其他应用的缓存)

1.3.0 (2026-10-17)

  • 修复:连接管理重构——换连接串时旧 ConnectionMultiplexer 显式 Dispose(原泄漏 socket/心跳定时器);短暂断连不再每次重建连接(消除连接风暴);实例持有自己的连接引用;Set(key,value,seconds) 参数校验;Get<T> key 判空
  • 变更:Set(key, value) 由"永不过期"改为默认 1 天过期(与 Memory/CSRedis 实现对齐),依赖永久缓存的调用方请显式传过期时间
  • 新增:静态 Shutdown 方法用于进程退出时释放连接
Product 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 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. 
.NET Framework net451 is compatible.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 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.3.1 84 10/20/2026
1.1.0 240 7/29/2025
1.0.1 645 7/18/2022
1.0.0 635 9/10/2021