public static IServiceCollection ConfigureRedisCache(this IServiceCollection services, Action <RedisCacheSettings> redisCacheSettingspAction) { var redisCacheSettings = new RedisCacheSettings(); redisCacheSettingspAction.Invoke(redisCacheSettings); services.AddSingleton(factory => redisCacheSettings); services.AddSingleton <IConnectionMultiplexer>(_ => ConnectionMultiplexer.Connect(redisCacheSettings.ConnectionString)); services.AddStackExchangeRedisCache(options => options.Configuration = redisCacheSettings.ConnectionString); services.AddSingleton <IRedisCacheService, RedisCacheService>(); return(services); }
public RedisCacheService(IDistributedCache distributedCache, RedisCacheSettings redisCacheSettings) { _distributedCache = distributedCache; _redisCacheSettings = redisCacheSettings; }