Installation
Install and register Redis persistence for TickerQ.
Install
dotnet add package TickerQ.Caching.StackExchangeRedisRegister
Chain .AddStackExchangeRedis() on TickerOptionsBuilder:
builder.Services.AddTickerQ(opt =>
{
opt.AddStackExchangeRedis(redis =>
{
redis.Configuration = "localhost:6379";
});
});You must provide at least one of Configuration, ConfigurationOptions, or ConnectionMultiplexer. TickerQ throws InvalidOperationException at startup if none is set. If you provide multiple settings, ConnectionMultiplexer takes precedence over Configuration and ConfigurationOptions.
Passing a pre-built multiplexer
If you already have an IConnectionMultiplexer instance, register it as a singleton so the host disposes it and pass that shared instance to TickerQ:
builder.Services.AddSingleton<IConnectionMultiplexer>(_ =>
ConnectionMultiplexer.Connect("localhost:6379"));
builder.Services.AddTickerQ((sp, opt) =>
{
opt.AddStackExchangeRedis(redis =>
{
redis.ConnectionMultiplexer = sp.GetRequiredService<IConnectionMultiplexer>();
});
});Using a factory
Using the ConnectionMultiplexerFactory property inherited from RedisCacheOptions:
builder.Services.AddTickerQ((sp, opt) =>
{
opt.AddStackExchangeRedis(redis =>
{
redis.ConnectionMultiplexerFactory = async () => await ConnectionMultiplexer.ConnectAsync(redisConnectionString);
});
});DI isolation — TickerQ registers its own
IConnectionMultiplexerandIDatabaseunder the keyed DI key"tickerq". It never touches the host application's unkeyedIConnectionMultiplexerregistration.