Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public RedisCacheService(IDistributedCache distributedCache, RedisCacheSettings redisCacheSettings)
 {
     _distributedCache   = distributedCache;
     _redisCacheSettings = redisCacheSettings;
 }