public RedisPlatformMemoryCache(IMemoryCache memoryCache , IConnectionMultiplexer connection , ISubscriber bus , IOptions <CachingOptions> cachingOptions , IOptions <RedisCachingOptions> redisCachingOptions , ILogger <RedisPlatformMemoryCache> log , TelemetryClient telemetryClient ) : base(memoryCache, cachingOptions, log) { _connection = connection; _log = log; _telemetryClient = telemetryClient; _bus = bus; _cachingOptions = cachingOptions.Value; _redisCachingOptions = redisCachingOptions.Value; connection.ConnectionFailed += OnConnectionFailed; connection.ConnectionRestored += OnConnectionRestored; _bus.Subscribe(_redisCachingOptions.ChannelName, OnMessage, CommandFlags.FireAndForget); _log.LogInformation($"{nameof(RedisPlatformMemoryCache)}: subscribe to channel {_redisCachingOptions.ChannelName } current instance:{ ServerId }"); _telemetryClient.TrackEvent("RedisSubscribed", new Dictionary <string, string> { { "channelName", _redisCachingOptions.ChannelName }, { "cacheId", ServerId } }); }
public RedisPlatformMemoryCache(IMemoryCache memoryCache , IConnectionMultiplexer connection , ISubscriber bus , IOptions <CachingOptions> cachingOptions , IOptions <RedisCachingOptions> redisCachingOptions , ILogger <RedisPlatformMemoryCache> log ) : base(memoryCache, cachingOptions, log) { _connection = connection; _log = log; _bus = bus; _cachingOptions = cachingOptions.Value; _redisCachingOptions = redisCachingOptions.Value; CancellableCacheRegion.OnTokenCancelled = CacheCancellableTokensRegistry_OnTokenCancelled; }
public RedisPlatformMemoryCache(IMemoryCache memoryCache, IOptions <CachingOptions> options , ISubscriber bus , IOptions <RedisCachingOptions> redisCachingOptions , ILogger <RedisPlatformMemoryCache> log ) : base(memoryCache, options, log) { _log = log; _bus = bus; _redisCachingOptions = redisCachingOptions.Value; _bus.Unsubscribe(_redisCachingOptions.ChannelName); _bus.Subscribe(_redisCachingOptions.ChannelName, OnMessage); _log.LogInformation($"{nameof(RedisPlatformMemoryCache)}: subscribe to channel {_redisCachingOptions.ChannelName } current instance:{ _cacheId }"); _retryPolicy = Policy.Handle <Exception>().WaitAndRetry( _redisCachingOptions.BusRetryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt - 1))); }