Redis failover with StackExchange / Sentinel from C#

后端 未结 4 1813
北恋
北恋 2020-12-24 08:58

We\'re currently using Redis 2.8.4 and StackExchange.Redis (and loving it) but don\'t have any sort of protection against hardware failures etc at the moment. I\'m trying to

4条回答
  •  春和景丽
    2020-12-24 09:32

    Today (I just configured StackExchange.Redis 2.1.58 to use sentinel) it's enough to specify a sentinel endpoint and serviceName in the redis connection string or Configuration. All the rest has been encapsulated as a part of this commit. So you just point stackexchange.redis to your sentinel nodes and ConnectionMuliplexer gives you up and running IDatabase each time you call GetDatabase().

    var conn = ConnectionMultiplexer.Connect("sentinel:26379,serviceName=mymaster");
    var db = conn.GetDatabase();
    db.StringSet("key", "value");
    

提交回复
热议问题