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 RedisStorage(string connectionString, RedisStorageOptions options = null) { if (connectionString == null) { throw new ArgumentNullException("connectionString"); } if (options == null) { options = new RedisStorageOptions(); } _connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); _invisibilityTimeout = options.InvisibilityTimeout; var endpoint = _connectionMultiplexer.GetEndPoints()[0]; if (endpoint is IPEndPoint) { var ipEp = endpoint as IPEndPoint; ConnectionString = string.Format("{0}:{1}", TryGetHostName(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(); }
public RedisStorage(string connectionString, RedisStorageOptions options = null) { if (connectionString == null) throw new ArgumentNullException("connectionString"); if (options == null) options = new RedisStorageOptions(); _connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); _invisibilityTimeout = options.InvisibilityTimeout; var endpoint = _connectionMultiplexer.GetEndPoints()[0]; if (endpoint is IPEndPoint) { var ipEp = endpoint as IPEndPoint; ConnectionString = string.Format("{0}:{1}", TryGetHostName(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(); }
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="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); }
private void Init(IConnectionMultiplexer connectionMultiplexer, RedisStorageOptions options) { _invisibilityTimeout = options.InvisibilityTimeout; _fetchTimeout = options.FetchTimeout; ConnectionString = connectionMultiplexer.Configuration; Db = options.Db; if (Prefix != options.Prefix) { Prefix = options.Prefix; } }
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(string hostAndPort, int db, RedisStorageOptions options) { if (hostAndPort == null) throw new ArgumentNullException("hostAndPort"); if (options == null) throw new ArgumentNullException("options"); HostAndPort = hostAndPort; Db = db; Options = options; _pooledManager = new PooledRedisClientManager( new []{ HostAndPort }, new string[0], new RedisClientManagerConfig { DefaultDb = Db, MaxWritePoolSize = Options.ConnectionPoolSize }); }
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()); }
private void Init(ConnectionMultiplexer connectionMultiplexer, RedisStorageOptions options) { _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; } }
public RedisStorage(string hostAndPort, int db, RedisStorageOptions options) { if (hostAndPort == null) { throw new ArgumentNullException("hostAndPort"); } if (options == null) { throw new ArgumentNullException("options"); } HostAndPort = hostAndPort; Db = db; Options = options; _pooledManager = new PooledRedisClientManager( new [] { HostAndPort }, new string[0], new RedisClientManagerConfig { DefaultDb = Db, MaxWritePoolSize = Options.ConnectionPoolSize }); }
/// <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); }
/// <summary> /// 启用基于CSRedisCore实现的Redis存储 /// </summary> /// <param name="configuration">Hangfire全局配置</param> /// <param name="nameOrConnectionString">连接字符串</param> /// <param name="options">Redis存储选项配置</param> public static IGlobalConfiguration <RedisStorage> UseRedisStorage([NotNull] this IGlobalConfiguration configuration, [NotNull] string nameOrConnectionString, RedisStorageOptions options = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (nameOrConnectionString == null) { throw new ArgumentNullException(nameof(nameOrConnectionString)); } var storage = new RedisStorage(nameOrConnectionString, options); return(configuration.UseStorage(storage)); }
/// <summary> /// 启用基于CSRedisCore实现的Redis存储 /// </summary> /// <param name="configuration">Hangfire全局配置</param> /// <param name="redisClient">CSRedisCore客户端</param> /// <param name="options">Redis存储选项配置</param> public static IGlobalConfiguration <RedisStorage> UseRedisStorage([NotNull] this IGlobalConfiguration configuration, [NotNull] CSRedisClient redisClient, RedisStorageOptions options = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (redisClient == null) { throw new ArgumentNullException(nameof(redisClient)); } var storage = new RedisStorage(redisClient, options); return(configuration.UseStorage(storage)); }