4

I'm using redis hashes to store metadata associated with a single key which in my case is userId. I have a batchAPI where I pass in a batch of userIds and get the metadata back. Redis Cluster doesn't support multi key commands so What's the best way to achieve this with RedisCluster? I am using Jedis as the Java Client to connect to Redis.

Phoenix
  • 8,695
  • 16
  • 55
  • 88
  • 1
    You can arrange for a user meta data hash to be stored in the same hash slot as the user's key with hashtags. If the metadata is on a different slot and/or multiple users are across multiple slots, you'll have to fetch the data separately from each shard and handle `MOVED` messages. I'm not sure whether Jedis does that for you on the fly or for batches (?) but you can try asking its mailing list: https://groups.google.com/forum/#!forum/jedis_redis – Itamar Haber Apr 14 '15 at 18:06

1 Answers1

4

If Lettuce is an option for you, then from 4.0.Final MGET on cluster is supported:

The cluster API was extended to run a command on multiple nodes and invocation to multi-key commands DEL, MGET, MSET and MSETNX perform automatic pipelining if the keys belong to different slots/masters.

(Source: https://github.com/mp911de/lettuce/releases/tag/4.0.Final)

Zsolt Katona
  • 1,373
  • 1
  • 8
  • 11