void Configure_region_expiration_from_config_element()
        {
            var configElement = new RedisCacheElement("region", TimeSpan.FromMinutes(99));
            var props = new Dictionary<string, string>();
            var sut = new RedisCache("region", props, configElement, ConnectionMultiplexer, options);

            sut.Put(999, new Person("Foo", 10));

            var cacheKey = sut.CacheNamespace.GetKey(999);
            var expiry = Redis.KeyTimeToLive(cacheKey);
            Assert.InRange(expiry.Value, low: TimeSpan.FromMinutes(98), high: TimeSpan.FromMinutes(99));
        }
        void Configure_region_expiration_from_config_element()
        {
            var configElement = new RedisCacheElement("region", TimeSpan.FromMinutes(99));
            var props         = new Dictionary <string, string>();
            var sut           = new RedisCache("region", props, configElement, ConnectionMultiplexer, options);

            sut.Put(999, new Person("Foo", 10));

            var cacheKey = sut.CacheNamespace.GetKey(999);
            var expiry   = Redis.KeyTimeToLive(cacheKey);

            Assert.InRange(expiry.Value, low: TimeSpan.FromMinutes(98), high: TimeSpan.FromMinutes(99));
        }
        public void Configure_region_expiration_from_config_element()
        {
            // Arrange
            var configElement = new RedisCacheElement("region", TimeSpan.FromMinutes(99));
            var props = new Dictionary<string, string>();
            var cache = new RedisCache("region", props, configElement, this.ClientManager);

            // Act
            cache.Put(999, new Person("Foo", 10));

            // Assert
            var cacheKey = cache.CacheNamespace.GlobalCacheKey(999);
            var expiry = Redis.GetTimeToLive(cacheKey);
            Assert.True(expiry >= TimeSpan.FromMinutes(98) && expiry <= TimeSpan.FromMinutes(99));
        }
Ejemplo n.º 4
0
        public void Configure_region_expiration_from_config_element()
        {
            // Arrange
            var configElement = new RedisCacheElement("region", TimeSpan.FromMinutes(99));
            var props         = new Dictionary <string, string>();
            var cache         = new RedisCache("region", props, configElement, this.ClientManager);

            // Act
            cache.Put(999, new Person("Foo", 10));

            // Assert
            var cacheKey = cache.CacheNamespace.GlobalCacheKey(999);
            var expiry   = Redis.GetTimeToLive(cacheKey);

            Assert.True(expiry >= TimeSpan.FromMinutes(98) && expiry <= TimeSpan.FromMinutes(99));
        }
 public RequestRecoveryRedisCache(string regionName, IDictionary <string, string> properties, RedisCacheElement element, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
     : base(regionName, properties, element, connectionMultiplexer, options)
 {
 }
        protected override RedisCache BuildCache(string regionName, IDictionary <string, string> properties, RedisCacheElement configElement, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            var cache = new MyRedisCache(regionName, properties, configElement, connectionMultiplexer, options);

            return(cache);
        }
Ejemplo n.º 7
0
        protected override RedisCache BuildCache(string regionName, IDictionary <string, string> properties, RedisCacheElement configElement, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            options.OnException = (e) =>
            {
                var httpContext = HttpContext.Current;
                if (httpContext != null)
                {
                    httpContext.Items[RequestRecoveryRedisCache.SkipNHibernateCacheKey] = true;
                }
            };

            return(new RequestRecoveryRedisCache(regionName, properties, configElement, connectionMultiplexer, options));
        }