コード例 #1
0
        public RedisStorefrontMemoryCache(IMemoryCache memoryCache, IOptions <StorefrontOptions> options
                                          , ISubscriber bus
                                          , IOptions <RedisCachingOptions> redisCachingOptions
                                          , ILoggerFactory loggerFactory
                                          ) : base(memoryCache, options, loggerFactory)
        {
            _log = loggerFactory?.CreateLogger <RedisStorefrontMemoryCache>();
            _bus = bus;

            _redisCachingOptions = redisCachingOptions.Value;
            _bus.Subscribe(_redisCachingOptions.ChannelName, OnMessage);

            _retryPolicy = Policy.Handle <Exception>().WaitAndRetry(
                _redisCachingOptions.BusRetryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt - 1)));
        }
コード例 #2
0
        public RedisStorefrontMemoryCache(IMemoryCache memoryCache
                                          , IOptions <StorefrontOptions> cachingOptions
                                          , IOptions <RedisCachingOptions> redisCachingOptions
                                          , IWorkContextAccessor workContextAccessor
                                          , ILoggerFactory loggerFactory
                                          ) : base(memoryCache, cachingOptions, loggerFactory, workContextAccessor)
        {
            _connection = ConnectionMultiplexer.Connect(redisCachingOptions.Value.Configuration);
            _log        = loggerFactory?.CreateLogger <RedisStorefrontMemoryCache>();
            _bus        = _connection.GetSubscriber();

            _redisCachingOptions = redisCachingOptions.Value;
            _storefrontOptions   = cachingOptions.Value;

            CacheCancellableTokensRegistry.OnTokenCancelled = CacheCancellableTokensRegistry_OnTokenCancelled;
        }
コード例 #3
0
        public RedisStorefrontMemoryCache(IMemoryCache memoryCache
                                          , IOptions <StorefrontOptions> cachingOptions
                                          , IOptions <RedisCachingOptions> redisCachingOptions
                                          , IWorkContextAccessor workContextAccessor
                                          , ILoggerFactory loggerFactory
                                          ) : base(memoryCache, cachingOptions, loggerFactory, workContextAccessor)
        {
            _connection = ConnectionMultiplexer.Connect(redisCachingOptions.Value.Configuration);

            _redisCachingOptions = redisCachingOptions.Value;
            _storefrontOptions   = cachingOptions.Value;

            _connection.ConnectionFailed   += OnConnectionFailed;
            _connection.ConnectionRestored += OnConnectionRestored;

            _bus = _connection.GetSubscriber();
            _bus.Subscribe(_redisCachingOptions.ChannelName, OnMessage, CommandFlags.FireAndForget);
        }