我们将使用ServiceStack.RedisClient,但我无法弄清楚如何为哨兵和主人定义密码。
我试过pwd @ ipv4:port但没有结果。
我们的代码是:
var sentinelHosts = new[] { "node1:26379", "node2:26379", "node3:26379" };
var sentinel = new RedisSentinel(sentinelHosts, "mymaster");
var manager = sentinel.Start();
while (true)
{
using (var client = manager.GetClient())
{
try
{
Console.WriteLine(client.IncrementValue("MyTestKey"));
}
catch (RedisException ex)
{
Console.WriteLine($"Error {ex.Message}");
}
}
Thread.Sleep(1000);
}
答案 0 :(得分:2)
您可以指定使用密码连接到Custom Redis Connection String的主/从,例如:
sentinel.HostFilter = host => "pwd@{0}".Fmt(host);