public RedisStorage(string connectionString, RedisStorageOptions options = null) { if (connectionString == null) { throw new ArgumentNullException("connectionString"); } var redisOptions = ConfigurationOptions.Parse(connectionString); if (options == null) { options = new RedisStorageOptions { Db = redisOptions.DefaultDatabase.GetValueOrDefault(0) } } ; _connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); _connectionMultiplexer.PreserveAsyncOrder = false; Init(_connectionMultiplexer, options); identity = Guid.NewGuid().ToString(); _subscription = new RedisSubscription(_connectionMultiplexer.GetSubscriber()); }
public RedisConnection( [NotNull] RedisStorage storage, [NotNull] IDatabase redis, [NotNull] RedisSubscription subscription, [NotNull] string jobStorageIdentity, TimeSpan fetchTimeout) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } if (redis == null) { throw new ArgumentNullException(nameof(redis)); } if (subscription == null) { throw new ArgumentNullException(nameof(subscription)); } if (jobStorageIdentity == null) { throw new ArgumentNullException(nameof(jobStorageIdentity)); } _storage = storage; _subscription = subscription; _jobStorageIdentity = jobStorageIdentity; _fetchTimeout = fetchTimeout; Redis = redis; }
public RedisConnection(IDatabase redis, RedisSubscription subscription, string jobStorageIdentity, TimeSpan fetchTimeout) { _subscription = subscription; _jobStorageIdentity = jobStorageIdentity; _fetchTimeout = fetchTimeout; Redis = redis; }
public RedisStorage(IConnectionMultiplexer connectionMultiplexer, RedisStorageOptions options = null) { _options = options ?? new RedisStorageOptions(); _connectionMultiplexer = connectionMultiplexer ?? throw new ArgumentNullException(nameof(connectionMultiplexer)); _subscription = new RedisSubscription(this, _connectionMultiplexer.GetSubscriber()); }
/// <summary> /// 初始化一个<see cref="RedisConnection"/>类型的实例 /// </summary> /// <param name="storage">Redis存储</param> /// <param name="redisClient">Redis客户端</param> /// <param name="subscription">Redis订阅</param> /// <param name="fetchTimeout">拉取超时时间</param> public RedisConnection([NotNull] RedisStorage storage , CSRedisClient redisClient , [NotNull] RedisSubscription subscription , TimeSpan fetchTimeout) { _storage = storage ?? throw new ArgumentNullException(nameof(storage)); _subscription = subscription ?? throw new ArgumentNullException(nameof(subscription)); _fetchTimeout = fetchTimeout; RedisClient = redisClient; }
/// <summary> /// 初始化一个<see cref="RedisClient"/>类型的实例 /// </summary> /// <param name="connectionString">连接字符串</param> /// <param name="options">Redis存储选项配置</param> public RedisStorage(string connectionString, RedisStorageOptions options = null) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } // TODO: 此处需要对连接字符串进行解析 _options = options ?? new RedisStorageOptions(); RedisClient = new CSRedisClient(connectionString); _subscription = new RedisSubscription(this, RedisClient); }
public RedisConnection( [NotNull] RedisStorage storage, [NotNull] IDatabase redis, [NotNull] RedisSubscription subscription, TimeSpan fetchTimeout) { _storage = storage ?? throw new ArgumentNullException(nameof(storage)); _subscription = subscription ?? throw new ArgumentNullException(nameof(subscription)); _fetchTimeout = fetchTimeout; Redis = redis ?? throw new ArgumentNullException(nameof(redis)); }
public RedisStorage(IConnectionMultiplexer connectionMultiplexer, RedisStorageOptions options = null) { if (connectionMultiplexer == null) { throw new ArgumentNullException(nameof(connectionMultiplexer)); } _options = options ?? new RedisStorageOptions(); _connectionMultiplexer = connectionMultiplexer; _identity = Guid.NewGuid().ToString(); _subscription = new RedisSubscription(this, _connectionMultiplexer.GetSubscriber()); }
public RedisStorage(string connectionString, RedisStorageOptions options = null) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } var redisOptions = ConfigurationOptions.Parse(connectionString); _options = options ?? new RedisStorageOptions { Db = redisOptions.DefaultDatabase ?? 0 }; _connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); _subscription = new RedisSubscription(this, _connectionMultiplexer.GetSubscriber()); }
public RedisStorage(ConnectionMultiplexer connectionMultiplexer, RedisStorageOptions options = null) { if (connectionMultiplexer == null) { throw new ArgumentNullException("connectionMultiplexer"); } if (options == null) { options = new RedisStorageOptions(); } _connectionMultiplexer = connectionMultiplexer; Init(_connectionMultiplexer, options); identity = Guid.NewGuid().ToString(); _subscription = new RedisSubscription(_connectionMultiplexer.GetSubscriber()); }
public RedisStorage(string connectionString, RedisStorageOptions options = null) { if (connectionString == null) { throw new ArgumentNullException("connectionString"); } if (options == null) { options = new RedisStorageOptions(); } _connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); _connectionMultiplexer.PreserveAsyncOrder = false; _invisibilityTimeout = options.InvisibilityTimeout; _fetchTimeout = options.FetchTimeout; var endpoint = _connectionMultiplexer.GetEndPoints()[0]; if (endpoint is IPEndPoint) { var ipEp = endpoint as IPEndPoint; ConnectionString = string.Format("{0}:{1}", ipEp.Address, ipEp.Port); } else { var dnsEp = endpoint as DnsEndPoint; ConnectionString = string.Format("{0}:{1}", dnsEp.Host, dnsEp.Port); } Db = options.Db; if (Prefix != options.Prefix) { Prefix = options.Prefix; } identity = Guid.NewGuid().ToString(); _subscription = new RedisSubscription(_connectionMultiplexer.GetSubscriber()); }
/// <summary> /// 初始化一个<see cref="RedisClient"/>类型的实例 /// </summary> /// <param name="redisClient">Redis客户端</param> /// <param name="options">Redis存储选项配置</param> public RedisStorage(CSRedisClient redisClient, RedisStorageOptions options = null) { RedisClient = redisClient; _options = options ?? new RedisStorageOptions(); _subscription = new RedisSubscription(this, redisClient); }