Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get all values for a Redis set in one operation?

Tags:

redis

Say I add two keys:

SET husband Bob
SET wife Alice

Then add these to a set:

SADD family husband wife

I can get the keys of this set with SMEMBERS family, which will return:

1) "wife"
2) "husband"

What I really want is the values:

1) "Alice"
2) "Bob"

Is this possible, in one operation? Essentially, I want to pipeline SMEMBERS with MGET.

like image 292
Deane Avatar asked Jan 22 '16 20:01

Deane


1 Answers

SMEMBERS, but if the Set is big enough your database will take time to return all the members, during which it will be blocked. In such cases the use of SSCAN is recommended.

EDIT: missed the question itself :) use SORT family BY nosort GET *

like image 172
Itamar Haber Avatar answered Oct 03 '22 21:10

Itamar Haber