Add MHGET - command to get fields from multiple hashes #7347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new command, which is a mix of MGET and HGET. It allows you to query for fields from multiple hashes in one command:
I find this useful in a few cases. The main use-case I have currently is that we store user experiment assignments in Redis, as one hash per experiment, one field per user, value is the assignment group. By having the hash be per experiment, we can easily drop the hash once the experiment is over (we actually
HSCANthrough the hash to delete fields in batches before dropping the key, to not pay theO(N)cost in a single query). The drawback of this structure is that we need to execute severalHGETcommands to get all experiment assignments for a specific user. (We have usually <20 active experiments, but 10s of millions of active users).I thought I'd propose a specific command for this use-case. I apologize for not going through the flow recommended in the contributing guidelines, of posting to the mailing list first. I wanted to build something, code in C again after a long break. If this isn't deemed a fit in Redis I don't consider the hour I spent coding and learning the codebase wasted. If you think it's worth posting about this on the mailing list to solicit more feedback I'm more than happy to do so.
I think
MHGETis slightly unfortunate as a command name. All other hash commands start withH. PerhapsHMHGETcould work?