Shubham
Shubham

Reputation: 297

How to fetch hash values for multiple keys in redis ? Is there a mhgetall operation?

HSET myhash field2 "Hi" field3 "World"
HSET myhash2 field2 "Hi" field3 "World"

I want to fetch the key-values for mhash and myhash2 in one operation. how to do this ?

Upvotes: 0

Views: 45

Answers (3)

Afeather2017
Afeather2017

Reputation: 1

You want to get/modify the two keys in a single query to save some network transports? Do this in batch. If you want it, then you have to take the power of pipeline:

https://redis.io/docs/latest/develop/use/pipelining/

(printf 'HSET myhash field2 "Hi" field3 "World"\r\nHSET myhash2 field2 "Hi" field3 "World"\r\n'; sleep 1) | nc localhost 6379

Upvotes: 0

Williams
Williams

Reputation: 1

you can use this command. hgetall "key"

Upvotes: 0

Ankit Sahay
Ankit Sahay

Reputation: 2043

There is no native way that redis supports fetching keys of two hash-maps in one operation

Upvotes: 1

Related Questions