StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.9k stars 1.51k forks source link

Issues performing operations in a sentinel configurations. #1676

Closed rms1234567890 closed 3 years ago

rms1234567890 commented 3 years ago

I'm having issues performang operations on a redis ha cluster. Following is my c# sample.

ConfigurationOptions configuration = new ConfigurationOptions
{
      Ssl = false,
      ServiceName = "redismaster",
      CommandMap = CommandMap.Sentinel
};

/// sentinels
///
configuration.EndPoints.Add("localhost", 10021);
configuration.EndPoints.Add("localhost", 10022);
configuration.EndPoints.Add("localhost", 10023);

IConnectionMultiplexer connection = ConnectionMultiplexer.SentinelConnect(configuration, Console.Out);

IDatabase database = connection.GetDatabase();

database.StringSetAsync("key", "value");

Error

This operation has been disabled in the command-map and cannot be used: SET

Full solution, redis setup for running in docker included in this repo https://github.com/rms1234567890/redis-sentinel

Is it something that I'm missing or this is an issue ?

NickCraver commented 3 years ago

In the Sentinel case, if you're connecting to Sentinel it'll have everything it needs by ServiceName and the endpoint. You do not want to set the CommandMap here, because you're restricting the final server (whatever Sentinel is pointing you at) to that command map (only the commands Sentinel supports). In short: let the library handle it :)