This page covers the Redis-backed provider package ModularityKit.Mutator.Governance.Redis.
It is the storage and query backend for governed requests. The package implements the public request store and query store contracts while keeping Redis-specific persistence details internal.
Use the Redis provider when you want the governance model from ModularityKit.Mutator.Governance
but need a persistent backing store instead of in-memory state.
Typical reasons:
- you want request persistence across process restarts
- you want Redis-backed query projections for approval queues and decision history
- you want the same governance API surface with a different storage backend
- you want to share governed request state across multiple runtime instances
RedisGovernanceServiceCollectionExtensions.AddRedisGovernanceStore(...)
Registers the Redis-backed governance store and the query store against an existing
IConnectionMultiplexer.
using Microsoft.Extensions.DependencyInjection;
using ModularityKit.Mutator.Governance.Redis;
using StackExchange.Redis;
var services = new ServiceCollection();
var multiplexer = await ConnectionMultiplexer.ConnectAsync("localhost:6379");
services.AddRedisGovernanceStore(
multiplexer,
options => options.KeyPrefix = "modularitykit:governance");The extension method registers the provider-facing storage and query services against DI.
RedisMutationRequestStoreOptions.KeyPrefix scopes all Redis keys created by the provider.
Use a dedicated prefix per environment or application if you need isolation between deployments.
The examples use modularitykit:governance as a readable default.
RedisMutationRequestStoreOptions
Current option:
KeyPrefix- Redis key prefix used for all request data, indexes, and query projections
RedisMutationRequestStore
Implements:
IMutationRequestStoreIMutationRequestQueryStore
Use it through DI rather than constructing it directly unless you are testing internals.
The provider stores the data needed for:
- request documents
- decision and approval projections
- query indexes and queue membership
- optimistic concurrency state for request writes
The provider does not change the governance model. It only persists the same model through Redis.
RedisMutationRequestKeyspaceRedisMutationRequestDocumentKeyFactory
These types define the Redis naming and partitioning rules for request documents, indexes, and query views.
The Redis provider handles:
- request persistence
- query projection
- optimistic concurrency on request writes
- Redis index maintenance
- candidate selection for query execution
It does not change the governance model itself. It only replaces the in-memory storage backend with Redis-specific persistence and read paths.
services.AddRedisGovernanceStore(
multiplexer,
options => options.KeyPrefix = "modularitykit:governance");var requestStore = provider.GetRequiredService<IMutationRequestStore>();
var queryStore = provider.GetRequiredService<IMutationRequestQueryStore>();Once registered, the rest of the application uses the same request and query contracts as the in-memory provider.
- Connect to Redis with
StackExchange.Redis - Register the provider with
AddRedisGovernanceStore(...) - Resolve
IMutationRequestStoreandIMutationRequestQueryStorefrom DI - Use the normal governance request and query APIs