The current hash slot calculation algorithm stops at the first valid or invalid (without bytes inside) match of { and }

Supporting multiple hastags will help distributing keys evenly across slots in certain scenarios.

Current behaviour

127.0.0.1:30001> CLUSTER KEYSLOT foo{bar}zap
(integer) 5061
127.0.0.1:30001> CLUSTER KEYSLOT foo{bar}{zap}
(integer) 5061

Expected new behaviour

127.0.0.1:30001> CLUSTER KEYSLOT foo{bar}zap
(integer) 5061
127.0.0.1:30001> CLUSTER KEYSLOT foo{bar}{zap}
(integer) 4493

We can rollout this functionality under a config flag for backward compatibility.

Comment From: sundb

i can't follow you, can you elaborate on your use case? how to calculate the slot of `foo{bar}{zap}.

Comment From: sureshkmit

Hi @sundb, I have updated the comment with an example.

Comment From: ShooterIT

the reason why we use hash tag is to make these keys store in the same slot, even after slot balance, application can access these keys in one command, so why we need two hash tags? and how to calculate the slot of foo{bar}{zap}?