Symbol.Redis 1.1.0.17

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

// Install Symbol.Redis as a Cake Tool
#tool nuget:?package=Symbol.Redis&version=1.1.0.17                

Symbol.Redis

dotnet core

  • appsettings.json
{
    //Redis配置
    "RedisConfig": {
        //连接参数,例如IP:端口
        "connectionOptions": "127.0.0.1:6379,password=123456",
        //扇区号(从0开始,redis db index)
        "sector": 0,
        //前辍
        "prefix": "demo"
    }
}
  • Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.EnableHttp1AndHttp2();
builder.Services.AddControllers();

builder.Services.ConfigureRedis(builder.Configuration)  //注入Redis组件
                .AddSingleton<Demo>();                  //注入单例:Demo

var app = builder.Build();

//尝试调用
var demo= app.ApplicationServices.GetRequiredService<Demo>();
demo.Foo();

app.Run();
  • Demo.cs

using Symbol.Redis;
using Microsoft.Extensions.DependencyInjection;

public class Demo {
    private RedisSector _redisSector;
    
    public Demo(RedisSector redisSector){
        _redisSector = redisSector;  //来自依赖注入创建的单例对象
    }

    public void Foo(){
        //读取redis中的值,实际从redis的dbIndex(0)中读取,key为“demo:test”
        string value = await _redisSector.GetValueAsync("test");
        Console.WriteLine($"Demo Foo value: {value}");
    }
}

dotnet framework

  • redis.config.json,设置该文件为输出到目录
{
    //连接参数,例如IP:端口
    "connectionOptions": "127.0.0.1:6379,password=123456",
    //扇区号(从0开始,redis db index)
    "sector": 0,
    //前辍
    "prefix": "demo"
}
  • Program.cs
using Symbol.Redis;

class Program{
    static void Main(){
        //加载redis配置文件并创建实例
        var redisSector = RedisSector.Create("~/redis.config.json");

        //读取redis中的值,实际从redis的dbIndex(0)中读取,key为“demo:test”
        string value = await _redisSector.GetValueAsync("test");
        Console.WriteLine($"Demo Foo value: {value}");

        Console.ReadKey();
    }
}
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 was computed.  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. 
.NET Framework net20 is compatible.  net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 is compatible.  net46 is compatible.  net461 is compatible.  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.1.0.17 173 5/31/2023
1.1.0.16 176 4/11/2023
1.1.0.15 205 2/22/2023

Please see https://github.com/symbolspace/Symbol.Redis/ for more information.