public RedisStorage(RedisStorageOptions options) { if (options == null) { throw new ArgumentNullException(nameof(RedisStorageOptions)); } var connectionString = options.HangfireDb; _options = options; if (_options.ExpireAtDays <= 0) { _options.ExpireAtDays = 7; } if (connectionString == null) { throw new ArgumentNullException("connectionString"); } var cachekey = connectionString + options.DataBase; if (!_redisConnectionCache.TryGetValue(cachekey, out var redis)) { redis = new Lazy <IDatabase>(() => { var connection = ConnectionMultiplexer.Connect(connectionString); return(connection.GetDatabase(options.DataBase)); }); _redisConnectionCache.TryAdd(cachekey, redis); } this._redis = redis; }
public RedisStorage(IOptions <RedisStorageOptions> options) { if (options == null || options.Value == null) { throw new ArgumentNullException(nameof(RedisStorageOptions)); } var connectionString = options.Value.HangfireDb; _options = options.Value; if (_options.ExpireAtDays <= 0) { _options.ExpireAtDays = 7; } if (connectionString == null) { throw new ArgumentNullException("connectionString"); } connection = ConnectionMultiplexer.Connect(connectionString); _redis = connection.GetDatabase(options.Value.DataBase); }