Is there MGET analog for Redis hashes?

You can query hashes or any keys in pipeline, i.e. in one request to your redis instance. Actual implementation depends on your client, but with redis-py it’d look like this:

pipe = conn.pipeline()
pipe.hgetall('foo')
pipe.hgetall('bar')
pipe.hgetall('zar')
hash1, hash2, hash3 = pipe.execute()

Client will issue one request with 3 commands. This is the same technique that is used to add multiple values to a set at once.

Read more at http://redis.io/topics/pipelining

Leave a Comment