I’m under the impression that one should hash (i.e. sha3) their Redis key before adding data to it. (It might have even been with regard to memcache.) I don’t remember why I have this impression or where it came from but I can’t find anything to validate (or refute) it. The reasoning was the hash would help with even distribution across a cluster.
When using Redis (in either/both clustered and non-clustered modes) is it best pracatice to hash the key before calling SET? e.g. set(sha3("username:123"), "owlman123")
2
Answers
No, you shouldn’t hash the key. Redis Cluster hashes the key itself for the purpose of choosing the node:
You can also use hash tags to control which keys share the same slot.
It might be a good idea if your keys are very long, as recommended in the official documentation:
source: https://redis.io/docs/data-types/tutorial/#keys