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
9
9
{
10
10
public void Execute ( )
11
11
{
12
+ string AddPassword ( string host ) => $ "password@{ host } ";
13
+
12
14
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
+ } ;
15
19
var manager = sentinel . Start ( ) ;
16
20
17
- sentinel . OnWorkerError = exception => Console . WriteLine ( exception ) ;
21
+ sentinel . OnWorkerError = Console . WriteLine ;
18
22
19
23
while ( true )
20
24
{
21
25
try
22
26
{
23
27
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 ) ;
29
31
}
30
32
catch ( Exception ex )
31
33
{
You can’t perform that action at this time.
0 commit comments