MK.Redis.Core 10.0.3.1

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

MK.Redis.Core

麦康 Redis.Core 工具类

本工具类(与 MK.Redis 不同)只提供了以下基础属性/方法:

// 只读属性
IConnectionMultiplexer Multiplexer   // StackExchange.Redis.IConnectionMultiplexer

// 普通方法
IDatabase GetDb(int db = -1)   // Multiplexer.GetDatabase(db)

// 静态方法
// 基于 System.Text.Json 序列化/反序列化
static RedisValue Serialize<T>(T value)
static T Deserialize<T>(RedisValue value)

具体使用方法见下:

// 注入方式一
builder.Services.AddMKRedis("127.0.0.1:6379,name=ApplicationName");

// 注入方式二
builder.Services.AddMKRedis("127.0.0.1:6379", opts =>
{
    //opts.EndPoints.Add("127.0.0.1", 6379);   // 此处添加的地址不会删除连接字符串中已配置的地址

    opts.AbortOnConnectFail = false;   // 首次连接失败,不抛出异常,允许后台尝试重连,默认:true
    opts.KeepAlive = 30;   // 心跳间隔(秒),防止中间设备断开连接,默认:60

    opts.DefaultDatabase = 6;
    opts.ClientName = builder.Environment.ApplicationName;
});

// 若要在 Program.cs 将 IConnectionMultiplexer 用于其他 StackExchange.Redis 三方库,可以用以下方式
var multiplexer = app.Services.GetRequiredService<IConnectionMultiplexer>();

// 使用场景
public class DemoController(IMKRedis mkRedis)
{
    private readonly IDatabase _redis = mkRedis.GetDb();
    private readonly IConnectionMultiplexer _multiplexer = mkRedis.Multiplexer;

    // 向 Redis 写入字符串
    // await _redis.StringGetAsync("key")   // 仅支持 StackExchange.Redis 的原生方法

    // 默认集成(基于 System.Text.Json 序列化/反序列化)静态方法
    // MKRedis.Serialize<T>(T data)   // 返回 RedisValue
    // MKRedis.Deserialize<T>(RedisValue redisValue)   // 返回 T
}
Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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 is compatible.  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. 
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
10.0.3.1 46 6/7/2026