Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper redis-cluster MGET & MSET by being aware of hash tags #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link
Contributor

Ref: #177

This is a fix for the non-use of MGET & MSET when in redis-cluster mode.

We (carefully) examine the keys to determine which can be grouped together as they use the same hash tag and hence go to the same slot.

…h slots (which determines that all keys go to the same cluster node)
@eoghanmurray eoghanmurray force-pushed the cluster-hash-tag-mget-mset branch from 9f23f46 to 1491595 Compare November 19, 2020 14:57
@eoghanmurray
Copy link
Contributor Author

Just now realise that there is some similar prior work on this:
predis/predis#149
I think the hash slot checks also satisfy those conditions:

  • IF the key contains a { character.
  • AND IF there is a } character to the right of {
  • AND IF there are one or more characters between the first occurrence of { and the first occurrence of }.

This is embodied in the following logic:

        if key.count('{') == key.count('}') == 1 and \
           -1 < key.index('{') < key.index('}') - 1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant