Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackExchange.Redis How to Connect to Sentinel

I want to get notificated when a master changes

For this i wanted to connect to my sentinels but the connection Multiplexer tells me that the are not reachable.

What am I Doing wrong?

 ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:26380,localhost:26381,localhost:26382");
like image 490
Boas Enkler Avatar asked Sep 18 '25 11:09

Boas Enkler


1 Answers

You can try the (much) newer version of StackExchange.Redis which comes with sentinel mode feature. You can now connect in sentinel mode with connection string like this:

var conn = ConnectionMultiplexer.Connect("172.17.6.45:26379,serviceName=mymaster");

It will auto-discover current master and return a managed connection which will handle the failover for you. If you want to be notified for master change you can subscribe the ConnectionMultiplexer.ConfigurationChanged event.

like image 90
victor6510 Avatar answered Sep 21 '25 00:09

victor6510