Is there any command in Redis to get multiple key's values in a single query?
Actually, My Keys are all SETS so I want to get all of their value but as MEMBERS only take one KEY in argument, is this possible in a single query.
You cannot get the value of the multiple sets in one query. You have to query the database multiple times.
However, you can do operation which involves multiple sets using single query. The commands for this type of operations are:
SDIFF- Returns the members of the set resulting from the difference between the first set and all the successive sets.
SINTER- Returns the members of the set resulting from the intersection of all the given sets.
I think following docs may help you: http://redis.io/commands/sunion
I faced such problem and found this ability of Redis. If you need only values and don't need to know the key for value it is what you need.
I checked perfomance for more than 667 keys. And there are results below:
Method 1 is 667 sequential requests
Method 2 is 667 concurrent requests
Method 3 is using sunion
Not technically a single 'query'.
If you don't want a union, and you just want to save round-trip time, use pipelining. For example, transactions like-
multi
smembers mykey1
smembers mykey2
exec
Redis clients have pipeline mechanism, where all the queries will be queued in your application buffer and will be sent to redis server at once.
SSCANcommand.