SetCombine method throws exception: StackExchange.Redis.RedisCommandException: Multi-key operations must involve a single slot;
I am using SetCombine() method to find the difference between 2 sets . It throws an exception:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.DiscoverNewSharePointSiteCollection ---> StackExchange.Redis.RedisCommandException: Multi-key operations must involve a single slot; keys can use 'hash tags' to help this, i.e. '{/users/12345}/account' and '{/users/12345}/contacts' will always be in the same slot at StackExchange.Redis.ServerSelectionStrategy.Select(Message message)
at StackExchange.Redis.ConnectionMultiplexer.TryPushMessageToBridge[T](Message message, ResultProcessor<T> processor, ResultBox<T> resultBox, ServerEndPoint& server)
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor<T> processor, ServerEndPoint server)
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor<T> processor, ServerEndPoint server)
at StackExchange.Redis.RedisDatabase.SetCombine(SetOperation operation, RedisKey first, RedisKey second, CommandFlags flags)
How do I fix this ?
As the message says here, the key component is hash tags. See the example there? The bit between the {...} are hashed, and will go to the same slot in the cluster. The general form is:
{thingToHash}.restOfKey
If thingToHash is the same for 2 keys, they'll be on the same slot, and you can SetCombine() them :)