This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -9,23 +9,25 @@ public class MasterFailoverWithPassword
99 {
1010 public void Execute ( )
1111 {
12+ string AddPassword ( string host ) => $ "password@{ host } ";
13+
1214 var sentinelHosts = new [ ] { "127.0.0.1:26380" , "127.0.0.1:26381" , "127.0.0.1:26382" } ;
13- var sentinel = new RedisSentinel ( sentinelHosts , masterName : "mymaster" ) ;
14- sentinel . HostFilter = host => "password@{0}" . Fmt ( host ) ;
15+ var sentinel = new RedisSentinel ( sentinelHosts . Map ( AddPassword ) , masterName : "mymaster" ) {
16+ HostFilter = AddPassword ,
17+ SentinelHostFilter = AddPassword ,
18+ } ;
1519 var manager = sentinel . Start ( ) ;
1620
17- sentinel . OnWorkerError = exception => Console . WriteLine ( exception ) ;
21+ sentinel . OnWorkerError = Console . WriteLine ;
1822
1923 while ( true )
2024 {
2125 try
2226 {
2327 const string RedisKey = "my Name" ;
24- using ( var client = manager . GetClient ( ) )
25- {
26- var result = client . Get < string > ( RedisKey ) ;
27- Console . WriteLine ( "Redis Key: {0} \t Port: {1}" , result , client . Port ) ;
28- }
28+ using var client = manager . GetClient ( ) ;
29+ var result = client . Get < string > ( RedisKey ) ;
30+ Console . WriteLine ( "Redis Key: {0} \t Port: {1}" , result , client . Port ) ;
2931 }
3032 catch ( Exception ex )
3133 {
You can’t perform that action at this time.
0 commit comments