Genocs.Saga.Integrations.Redis

Genocs.Saga.Integrations.Redis — Agent Reference Documentation

Consumer Mode for Agents

  • Assume package is installed from NuGet.
  • Do not rely on repository source code access.
  • Prefer stable public APIs and extension methods documented here.
  • If behavior is uncertain, fail safely and request package version and configuration details.

Purpose

Genocs.Saga.Integrations.Redis replaces default in-memory saga persistence with Redis-backed saga state and saga log storage for distributed deployments.

Quick Facts

KeyValue
PackageGenocs.Saga.Integrations.Redis
Target frameworksnet10.0, net9.0, net8.0
Primary roleRedis persistence provider for saga state and logs
Main APIsUseRedisPersistence(ISagaBuilder, SagaRedisOptions), UseRedisPersistence(ISagaBuilder, string, IConfiguration)

Install

dotnet add package Genocs.Saga.Integrations.Redis

Minimal Integration Recipe (Program.cs)

using Genocs.Saga;
using Genocs.Saga.Integrations.Redis;
using Genocs.Saga.Integrations.Redis.Configurations;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSaga(saga =>
{
    saga.UseRedisPersistence(new SagaRedisOptions
    {
        Configuration = "localhost:6379",
        InstanceName = "genocs-saga"
    });
});

var app = builder.Build();
app.Run();

Configuration

{
  "sagaRedis": {
    "enabled": true,
    "configuration": "localhost:6379",
    "instanceName": "genocs-saga"
  }
}
SettingTypeDescription
configurationstringRedis connection string passed to AddStackExchangeRedisCache.
instanceNamestringCache key prefix used for saga state and log entries.

Dependencies

  • Genocs.Saga
  • Microsoft.Extensions.Caching.StackExchangeRedis
  • Newtonsoft.Json

Troubleshooting

  1. Saga data is not shared across service instances. Fix: Verify Redis connectivity and ensure UseRedisPersistence(...) is called in startup.
  2. Startup throws during Redis settings binding. Fix: Validate the configuration section value format and required fields (configuration, instanceName).