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(); }
/// <summary> /// Set the <see cref="StackExchange.Redis.ConnectionMultiplexer"/> to be used to /// connect to Redis. /// </summary> /// <param name="connectionMultiplexer"></param> public static void SetConnectionMultiplexer(ConnectionMultiplexer connectionMultiplexer) { lock (syncRoot) { if (connectionMultiplexerStatic != null) { throw new InvalidOperationException("The connection multiplexer can only be configured once."); } connectionMultiplexerStatic = connectionMultiplexer.ThrowIfNull(); } }
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); }