Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all members in Sorted Set

Tags:

redis

I have a Sorted set and want to get all members of set. How to identify a max/min score for command :

zrange key min max  

?

like image 806
Bdfy Avatar asked Jul 16 '12 12:07

Bdfy


1 Answers

You're in luck, as zrange does not take scores, but indices. 0 is the first index, and -1 will be interpreted as the last index:

zrange key 0 -1 

To get a range by score, you would call zrangebyscore instead -- where -inf and +inf can be used to denote negative and positive infinity, respectively, as Didier Spezia notes in his comment:

zrangebyscore key -inf +inf 
like image 191
Linus Thiel Avatar answered Sep 27 '22 21:09

Linus Thiel