谢谢老师的解答。老师忙完双十一了(#^.^#),使用的库为:StackExchange.Redis,我在Github找到了下面的配置:
private string ServiceName => TestConfig.Current.SentinelSeviceName;
private ConnectionMultiplexer Conn { get; }
private IServer Server { get; }
public ITestOutputHelper Output { get; }
public Sentinel(ITestOutputHelper output)
{
Output = output;
Skip.IfNoConfig(nameof(TestConfig.Config.SentinelServer), TestConfig.Current.SentinelServer);
Skip.IfNoConfig(nameof(TestConfig.Config.SentinelSeviceName), TestConfig.Current.SentinelSeviceName);
var options = new ConfigurationOptions()
{
CommandMap = CommandMap.Sentinel,
EndPoints = { { TestConfig.Current.SentinelServer, TestConfig.Current.SentinelPort } },
AllowAdmin = true,
TieBreaker = "",
ServiceName = TestConfig.Current.SentinelSeviceName,
SyncTimeout = 5000
};
Conn = ConnectionMultiplexer.Connect(options, Console.Out);
Thread.Sleep(3000);
Assert.True(Conn.IsConnected);
Server = Conn.GetServer(TestConfig.Current.SentinelServer, TestConfig.Current.SentinelPort);
}
我先试试,遇到问题再请教老师