RedisStorm 8.0.0

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

// Install RedisStorm as a Cake Tool
#tool nuget:?package=RedisStorm&version=8.0.0                

RedisStorm

This is a simple wrapper for StackExchange.Redis that would make using redis pub sub easier.

Features

  • You can use message pack serialization for better performance
  • Adding subscribers automatically and binding them to channels with attribute
  • Using built-in DI container for handling messages so that you can inject services inside your subscriber (message handler)

Installation

Using package manager:

Install-Package RedisStorm -Version 8.0.0

Usage/Examples

Setup

        services.AddRedisStorm(Assembly.GetExecutingAssembly(), factory =>
        {
        
            //Add multiplexer below
            factory.AddConnectionMultiplexer(multiplexer);
            // factory.AddConnectionMultiplexerFromServiceCollection();
            
            factory.AddPublisher(registrationFactory =>
            {
                registrationFactory.SerializationType = SerializationType.MessagePack;
            });

            factory.AddSubscribers(registrationFactory =>
            {
                //You can change type to message pack here (default is json)
                registrationFactory.SerializationType = SerializationType.MessagePack;
                
                //You can use below line for automaticaly registring subscribers
                registrationFactory.AddSubscribersFromAssembly(); 
                
                //Also you can add subscribers here manually with this method
                registrationFactory.ConfigSubscriber<SampleSubscriber>("channelName");
            });
        });

Subscriber

namespace RedisStorm.Test.Subscribers;

[RedisChannel("sample-channel")]
public class SampleSubscriber : ISubscriber<SampleMessage>
{
    public Task Handle(SampleMessage message, CancellationToken cancellationToken)
    {
        throw new NotImplementedException();
    }
}

You should use this attribute only when you want to bind subscriber automatically

Publisher

namespace RedisStorm.Test.Services;

private readonly IRedisPublisher _publisher;  
  
public TestService(IRedisPublisher publisher)  
{  
	_publisher = publisher;  
}

public async Task Test()
{
    _publisher.Publish("channel", new SampleMessage());
}

It only works when you call AddPublisher method in AddRedisStorm

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. 
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.