Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static IServiceCollection AddRedis(this IServiceCollection services, IConfiguration configuration)
{
var redisCacheSettings = new RedisOptions();
configuration.GetSection(SectionName).Bind(redisCacheSettings);
services.AddSingleton(redisCacheSettings);
if (!redisCacheSettings.Enabled)
{
return services;
}
services.AddSingleton<IConnectionMultiplexer>(_ => ConnectionMultiplexer.Connect(redisCacheSettings.ConnectionString));
services.AddStackExchangeRedisCache(options => options.Configuration = redisCacheSettings.ConnectionString);
services.AddSingleton<IResponseCacheService, ResponseCacheService>();
return services;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.