// Operations for Redis clients. public RedisNativeClient GetRedisClient(string ip, ushort port) { ulong key = Network.IPv4ToUlong(ip, port); RedisNativeClient client = null; if (!this.clients.TryGetValue(key, out client)) { client = new RedisNativeClient(ip, port); this.clients.Add(key, client); if ((this.password != null) && (this.password.Length > 0)) { client.RawCommand("AUTH", this.password); } } return(client); }
private void Update(RedisNativeClient client, string ip) { if (client == null) { Console.WriteLine("client == null"); return; } RedisData reply = null; try { reply = client.RawCommand("CLUSTER", "NODES"); } catch (RedisException e) { if (e.Message.Contains("cluster support disabled")) { Global.Info(ip, "Switch to non-cluster mode"); for (int i = 0; i < Global.HashSlotSize; i++) { this.slots[i] = client; } } else { Global.Error(ip, e.Message); } return; } if (reply != null) { this.ParseClusterNodes(reply.ToRedisText().Text, ip); } }