public InterceptorBeforeEventArgs(RedisClient cli, CommandPacket cmd) { this.Client = cli; this.Command = cmd; }
internal void ResetSentinel() { if (ResetSentinelFlag != 0) { return; } if (Interlocked.Increment(ref ResetSentinelFlag) != 1) { Interlocked.Decrement(ref ResetSentinelFlag); return; } string masterhostEnd = _masterHost; var allkeys = _ib.GetKeys().ToList(); for (int i = 0; i < _sentinels.Count; i++) { if (i > 0) { var first = _sentinels.First; _sentinels.RemoveFirst(); _sentinels.AddLast(first.Value); } try { using (var sentinelcli = new RedisSentinelClient(_sentinels.First.Value)) { var masterhost = sentinelcli.GetMasterAddrByName(_connectionString.Host); var masterConnectionString = localTestHost(masterhost, RoleType.Master); if (masterConnectionString == null) { continue; } masterhostEnd = masterhost; if (_rw_splitting) { foreach (var slave in sentinelcli.Salves(_connectionString.Host)) { ConnectionStringBuilder slaveConnectionString = localTestHost($"{slave.ip}:{slave.port}", RoleType.Slave); if (slaveConnectionString == null) { continue; } } } foreach (var sentinel in sentinelcli.Sentinels(_connectionString.Host)) { var remoteSentinelHost = $"{sentinel.ip}:{sentinel.port}"; if (_sentinels.Contains(remoteSentinelHost)) { continue; } _sentinels.AddLast(remoteSentinelHost); } } break; } catch { } } foreach (var spkey in allkeys) { _ib.TryRemove(spkey, true); } Interlocked.Exchange(ref _masterHost, masterhostEnd); Interlocked.Decrement(ref ResetSentinelFlag); ConnectionStringBuilder localTestHost(string host, RoleType role) { ConnectionStringBuilder connectionString = _connectionString.ToString(); connectionString.Host = host; connectionString.MinPoolSize = 1; connectionString.MaxPoolSize = 1; using (var cli = new RedisClient(connectionString)) { if (cli.Role().role != role) { return(null); } if (role == RoleType.Master) { //test set/get } } connectionString.MinPoolSize = connectionString.MinPoolSize; connectionString.MaxPoolSize = connectionString.MaxPoolSize; _ib.TryRegister(host, () => new RedisClientPool(connectionString, null, TopOwner)); allkeys.Remove(host); return(connectionString); } }
public ConnectedEventArgs(string host, RedisClientPool pool, RedisClient cli) { this.Host = host; this.Pool = pool; this.Client = cli; }
internal PipelineHook(RedisClient cli) : base(new PipelineAdapter(cli)) { this.Serialize = cli.Serialize; this.Deserialize = cli.Deserialize; }
internal GetSharingHook(RedisClient cli, BaseAdapter adapter) : base(adapter) { this.Serialize = cli.Serialize; this.Deserialize = cli.Deserialize; }
public TransactionAdapter(RedisClient cli) { UseType = UseType.Transaction; _cli = cli; _commands = new List <TransactionCommand>(); }
internal TransactionHook(RedisClient cli) : base(new TransactionAdapter(cli)) { this.Serialize = cli.Serialize; this.Deserialize = cli.Deserialize; }
public ClientSideCachingContext(RedisClient cli, ClientSideCachingOptions options) { _cli = cli; _options = options ?? new ClientSideCachingOptions(); }
public static void UseClientSideCaching(this RedisClient cli, ClientSideCachingOptions options) { new ClientSideCachingContext(cli, options) .Start(); }
public TransactionAdapter(RedisClient topOwner) { UseType = UseType.Transaction; TopOwner = topOwner; _commands = new List <TransactionCommand>(); }
/// <summary> /// Single inside RedisClient /// </summary> protected internal RedisClient(RedisClient topOwner, string host, bool ssl, TimeSpan connectTimeout, TimeSpan receiveTimeout, TimeSpan sendTimeout, Action <RedisClient> connected) { Adapter = new SingleInsideAdapter(topOwner ?? this, this, host, ssl, connectTimeout, receiveTimeout, sendTimeout, connected); }
internal PubSub(RedisClient topOwner) { _topOwner = topOwner; }