Aoxe.StackExchangeRedis.Abstractions 2024.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Aoxe.StackExchangeRedis.Abstractions --version 2024.2.2                
NuGet\Install-Package Aoxe.StackExchangeRedis.Abstractions -Version 2024.2.2                
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="Aoxe.StackExchangeRedis.Abstractions" Version="2024.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aoxe.StackExchangeRedis.Abstractions --version 2024.2.2                
#r "nuget: Aoxe.StackExchangeRedis.Abstractions, 2024.2.2"                
#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 Aoxe.StackExchangeRedis.Abstractions as a Cake Addin
#addin nuget:?package=Aoxe.StackExchangeRedis.Abstractions&version=2024.2.2

// Install Aoxe.StackExchangeRedis.Abstractions as a Cake Tool
#tool nuget:?package=Aoxe.StackExchangeRedis.Abstractions&version=2024.2.2                

Aoxe.Redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, HyperLogLogs, Bitmaps. http://redis.io

Introduction

This redis client wrappers and serializers.

QuickStart

NuGet

Install-Package Aoxe.StackExchangeRedis
Install-Package Aoxe.NewtonsoftJson

Build Project

Create an asp.net core project and import references in startup.cs. Get Aoxe.StackExchangeRedis and Aoxe.NewtonsoftJson from Nuget,otherwise we have other serializers:

Aoxe.Binary

Aoxe.Jil

Aoxe.MsgPack

Aoxe.Protobuf

Aoxe.SystemTextJson

Aoxe.Utf8Json

Aoxe.Xml

Aoxe.ZeroFormatter

using Aoxe.StackExchangeRedis;
using Aoxe.StackExchangeRedis.Abstractions;
using Aoxe.NewtonsoftJson;

Register AoxeRedisClient in Configuration like

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddSingleton<IAoxeRedisClient>(p =>
        new AoxeRedisClient(new AoxeStackExchangeRedisOptions
                {
                    ConnectionString = "192.168.78.140:6379,abortConnect=false,syncTimeout=3000"),
                    DefaultExpiry = TimeSpan.FromMinutes(10),
                    Serializer = new AoxeSerializer()
                });
}

Add a TestClass for the demo

public class TestModel
{
    public Guid Id { get; set; }

    public string Name { get; set; }

    public int Age { get; set; }

    public DateTime CreateTime { get; set; }
}

Create a controller like this

[Route("api/[controller]/[action]")]
[ApiController]
public class RedisDemoController : ControllerBase
{
    private readonly IAoxeRedisClient _redisHandler;

    public RedisDemoController(IAoxeRedisClient handler)
    {
        _redisHandler = handler;
    }

    [HttpGet]
    [HttpPost]
    public Guid Add()
    {
        var testModel = new TestModel
        {
            Id = Guid.NewGuid(),
            Name = "apple",
            Age = 18,
            CreateTime = DateTime.Now
        };
        _redisHandler.Add(testModel.Id.ToString(), testModel);
        return testModel.Id;
    }

    [HttpGet]
    [HttpPost]
    public List<string> AddRange(int quantity)
    {
        var testModles = new List<Tuple<string, TestModel>>();
        for (var i = 0; i < quantity; i++)
        {
            var id = Guid.NewGuid();
            testModles.Add(new Tuple<string, TestModel>(id.ToString(),
                new TestModel
                {
                    Id = id,
                    Name = "apple",
                    Age = 18,
                    CreateTime = DateTime.Now
                }));
        }

        _redisHandler.AddRange(testModles);

        return testModles.Select(p => p.Item1).ToList();
    }

    [HttpGet]
    [HttpPost]
    public void Delete(string key)
    {
        _redisHandler.Delete(key);
    }

    [HttpGet]
    [HttpPost]
    public void DeleteAll([FromBody]IList<string> keys)
    {
        _redisHandler.DeleteAll(keys);
    }

    [HttpGet]
    [HttpPost]
    public TestModel Get(string key)
    {
        return _redisHandler.Get<TestModel>(key);
    }

    [HttpGet]
    [HttpPost]
    public Dictionary<string, TestModel> GetAll([FromBody]IList<string> keys)
    {
        return _redisHandler.Get<TestModel>(keys);
    }
}

Now you can run a Postman and send some requests to try it.And the AoxeRedisClient has async methods like AddAsync/AddRangeAsync/DeleteAsync/DeleteAllAsync,you can try it yourself.

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 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 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 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Aoxe.StackExchangeRedis.Abstractions:

Package Downloads
Aoxe.StackExchangeRedis.Client

Redis wrappers base by StackExchange.Redis

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.2.4 323 9/6/2024
2024.2.2 98 9/6/2024
2024.2.0 168 6/15/2024
2024.1.1 132 6/13/2024
2024.1.0 99 6/13/2024