Get all members in Sorted Set

Redis

Redis Problem Overview


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 

?

Redis Solutions


Solution 1 - Redis

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBdfyView Question on Stackoverflow
Solution 1 - RedisLinus ThielView Answer on Stackoverflow