Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="connectionMultiplexer"></param>
        /// <param name="options"></param>
        public RedisCache(RedisCacheConfiguration configuration, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            configuration.ThrowIfNull("configuration")
            .Validate();
            RegionName          = configuration.RegionName;
            _expiration         = configuration.Expiration;
            _slidingExpiration  = configuration.SlidingExpiration;
            _lockTimeout        = configuration.LockTimeout;
            _acquireLockTimeout = configuration.AcquireLockTimeout;

            this._connectionMultiplexer = connectionMultiplexer.ThrowIfNull("connectionMultiplexer");
            this._options = options.ThrowIfNull("options")
                            .ShallowCloneAndValidate();


            Log.Debug("creating cache: regionName='{0}', expiration='{1}', lockTimeout='{2}', acquireLockTimeout='{3}'",
                      RegionName, _expiration, _lockTimeout, _acquireLockTimeout
                      );

            options.KeyPrefix = options.KeyPrefix.LastIndexOf(":", StringComparison.Ordinal) > -1
              ? options.KeyPrefix
              : options.KeyPrefix + ":";

            CacheNamespace = new RedisNamespace(options.KeyPrefix + RegionName);
        }
Пример #2
0
        public RedisCache(string regionName, IDictionary<string, string> properties, RedisCacheElement element, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            this.connectionMultiplexer = connectionMultiplexer.ThrowIfNull("connectionMultiplexer");
            this.options = options.ThrowIfNull("options").ShallowCloneAndValidate();

            RegionName = regionName.ThrowIfNull("regionName");

            if (element == null)
            {
                expiry = TimeSpan.FromSeconds(
                    PropertiesHelper.GetInt32(Cfg.Environment.CacheDefaultExpiration, properties, DefaultExpiry)
                );
            }
            else
            {
                expiry = element.Expiration;
            }

            log.DebugFormat("using expiration : {0} seconds", expiry.TotalSeconds);

            var @namespace = CacheNamePrefix + RegionName;

            CacheNamespace = new RedisNamespace(@namespace);
            SyncInitialGeneration();
        }
Пример #3
0
        public RedisCache(string regionName, IDictionary <string, string> properties, RedisCacheElement element, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            this.connectionMultiplexer = connectionMultiplexer.ThrowIfNull("connectionMultiplexer");
            this.options = options.ThrowIfNull("options").ShallowCloneAndValidate();

            RegionName = regionName.ThrowIfNull("regionName");

            if (element == null)
            {
                expiry = TimeSpan.FromSeconds(
                    PropertiesHelper.GetInt32(Cfg.Environment.CacheDefaultExpiration, properties, DefaultExpiry)
                    );
            }
            else
            {
                expiry = element.Expiration;
            }

            log.DebugFormat("using expiration : {0} seconds", expiry.TotalSeconds);

            var @namespace = CacheNamePrefix + RegionName;

            CacheNamespace = new RedisNamespace(@namespace);
            SyncInitialGeneration();
        }
        public RedisCache(RedisCacheConfiguration configuration, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            configuration.ThrowIfNull("configuration")
            .Validate();
            RegionName         = configuration.RegionName;
            expiration         = configuration.Expiration;
            slidingExpiration  = configuration.SlidingExpiration;
            lockTimeout        = configuration.LockTimeout;
            acquireLockTimeout = configuration.AcquireLockTimeout;

            this.connectionMultiplexer = connectionMultiplexer.ThrowIfNull("connectionMultiplexer");
            this.options = options.ThrowIfNull("options")
                           .ShallowCloneAndValidate();

            log.DebugFormat("creating cache: regionName='{0}', expiration='{1}', lockTimeout='{2}', acquireLockTimeout='{3}'",
                            RegionName, expiration, lockTimeout, acquireLockTimeout
                            );

            CacheNamespace = new RedisNamespace(options.KeyPrefix + RegionName);
        }
Пример #5
0
        public RedisCache(RedisCacheConfiguration configuration, ConnectionMultiplexer connectionMultiplexer, RedisCacheProviderOptions options)
        {
            configuration.ThrowIfNull("configuration")
                .Validate();
            RegionName = configuration.RegionName;
            expiration = configuration.Expiration;
            slidingExpiration = configuration.SlidingExpiration;
            lockTimeout = configuration.LockTimeout;
            acquireLockTimeout = configuration.AcquireLockTimeout;

            this.connectionMultiplexer = connectionMultiplexer.ThrowIfNull("connectionMultiplexer");
            this.options = options.ThrowIfNull("options")
                .ShallowCloneAndValidate();

            log.DebugFormat("creating cache: regionName='{0}', expiration='{1}', lockTimeout='{2}', acquireLockTimeout='{3}'", 
                RegionName, expiration, lockTimeout, acquireLockTimeout
            );

            CacheNamespace = new RedisNamespace(cacheNamespacePrefix + RegionName);
        }