Skip to content

Improve the MGet helper for the cluster client by using MGET commands #844

@fabiomargarido

Description

@fabiomargarido

Hey there.

I'm a bit confused by the wording in the comment and README regarding the MGet helper functions:

// MGet is a helper that consults the redis directly with multiple keys by grouping keys within the same slot into MGET or multiple GETs
func MGet(client Client, ctx context.Context, keys []string) (ret map[string]RedisMessage, err error) {

Specifically, the part where it says keys are grouped taking the slot into consideration, since looking at the code it seems it simply checks if the client is not a cluster client, in which case an MGET is sent, and falls back to a pipelined GET for each separate key when it is in fact a cluster.

I was wondering if it would be possible to pre-calculate the target slot for each key and send a separate MGET command to each node responsible the a particular set of slots. If this fails for some reason (e.g. cluster topology changed and refresh was not yet executed), then fallback to the current implementation.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions