Use redis MGET command using golang cluster client

Viewed 143

I have a redis instance running in cluster mode with 2 nodes. Using the "CLUSTER NODES" command I see can the 2 nodes as

myself,master - 0 0 0 connected 8192-16383
master - 0 1658945195368 1 connected 0-8191

Now when using the redis client for go i.e. "github.com/go-redis/redis/v8" and querying for keys that were present in different nodes I was getting the error: "CROSSSLOT Keys in request don't hash to the same slot"

I then used redis cluster client as defined here https://redis.uptrace.dev/guide/go-redis-cluster.html to solve this and using the cluster client I was able to resolve this issue for all hash related commands such as HGET, HGETALL, HSET etc. Now the issue is that even the cluster client is giving the same CROSSLOT error for non-hash commands such as GET, MGET, SET etc.

I know while creating the keys I can force all keys into the same SLOT as defined here:https://hackernoon.com/resolving-the-crossslot-keys-error-with-redis-cluster-mode-enabled but I have a large number of keys and I don't think forcing all of them into the same SLOT can be a good idea. Any suggestions on how can I achieve this?

0 Answers
Related