0
0
Redisquery~5 mins

ZRANGE and ZREVRANGE for reading in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command ZRANGE do?
It returns a range of members in a sorted set, ordered from the lowest to the highest score.
Click to reveal answer
beginner
How does ZREVRANGE differ from ZRANGE?
ZREVRANGE returns members in a sorted set ordered from the highest to the lowest score, reversing the order of ZRANGE.
Click to reveal answer
beginner
What do the start and stop parameters in ZRANGE key start stop represent?
They specify the index range of elements to return, where 0 is the first element, 1 the second, and so on. Negative numbers count from the end (-1 is last).
Click to reveal answer
intermediate
How can you include the scores of members when using ZRANGE or ZREVRANGE?
Add the WITHSCORES option to the command to get each member's score along with the member.
Click to reveal answer
beginner
If you want to get the top 3 highest scored members from a sorted set, which command would you use?
Use ZREVRANGE key 0 2 to get the first 3 members with the highest scores.
Click to reveal answer
What order does ZRANGE return members from a sorted set?
AAlphabetical order
BFrom highest to lowest score
CRandom order
DFrom lowest to highest score
Which command returns members from highest to lowest score?
AZRANGE
BZREVRANGE
CZADD
DZREM
What does the WITHSCORES option do when used with ZRANGE or ZREVRANGE?
AReturns members and their scores
BSorts members alphabetically
CReturns only scores
DDeletes members with scores
If you want the last 2 members in a sorted set using ZRANGE, what start and stop values do you use?
A1 2
B0 1
C-2 -1
D-1 0
Which command would you use to get the top 5 lowest scored members?
AZRANGE key 0 4
BZREVRANGE key 0 4
CZRANGE key -5 -1
DZREVRANGE key -5 -1
Explain how ZRANGE and ZREVRANGE commands work in Redis sorted sets.
Think about the order and how you specify which members to get.
You got /4 concepts.
    Describe how to retrieve the top 3 highest scored members from a Redis sorted set including their scores.
    Remember ZREVRANGE reverses the order to highest first.
    You got /3 concepts.