public static IConveyBuilder AddRedis(this IConveyBuilder builder, RedisOptions options) { if (!builder.TryRegister(RegistryName)) { return(builder); } builder.Services.AddStackExchangeRedisCache(o => { o.Configuration = options.ConnectionString; o.InstanceName = options.Instance; }); return(builder); }
public static IConveyBuilder AddRedis(this IConveyBuilder builder, RedisOptions options) { if (!builder.TryRegister(RegistryName)) { return(builder); } //TODO: Still 2.2 builder.Services.AddDistributedRedisCache(o => { o.Configuration = options.ConnectionString; o.InstanceName = options.Instance; }); return(builder); }
public static IConveyBuilder AddRedis(this IConveyBuilder builder, RedisOptions options) { if (!builder.TryRegister(RegistryName)) { return(builder); } builder.Services .AddSingleton(options) .AddSingleton <IConnectionMultiplexer>(sp => ConnectionMultiplexer.Connect(options.ConnectionString)) .AddTransient(sp => sp.GetRequiredService <IConnectionMultiplexer>().GetDatabase(options.Database)) .AddStackExchangeRedisCache(o => { o.Configuration = options.ConnectionString; o.InstanceName = options.Instance; }); return(builder); }