0
0
Redisquery~5 mins

ZRANGEBYLEX for lexicographic queries in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Redis command ZRANGEBYLEX do?

ZRANGEBYLEX returns members in a sorted set within a specified lexicographic range.

It sorts by dictionary order, not by score.

Click to reveal answer
beginner
How do you specify an inclusive range in ZRANGEBYLEX?

Use square brackets [ before the value.

Example: [apple means include 'apple' in the range.

Click to reveal answer
beginner
What symbols indicate exclusive range boundaries in ZRANGEBYLEX?

Use parentheses ( before the value.

Example: (apple means exclude 'apple' from the range.

Click to reveal answer
beginner
What do the special values - and + mean in ZRANGEBYLEX?

- means the smallest possible value (start of range).

+ means the largest possible value (end of range).

Click to reveal answer
beginner
Can ZRANGEBYLEX be used to query by score in Redis sorted sets?

No. ZRANGEBYLEX queries by lexicographic order of members, ignoring scores.

Use ZRANGEBYSCORE to query by score.

Click to reveal answer
What does ZRANGEBYLEX myset [a (c return?
AMembers from 'a' exclusive up to 'c' inclusive
BMembers from 'a' inclusive up to 'c' exclusive
CMembers from 'a' exclusive up to 'c' exclusive
DMembers from 'a' inclusive up to 'c' inclusive
Which command would you use to get all members lexicographically greater than 'mango'?
AZRANGEBYLEX myset (mango +
BZRANGEBYLEX myset [mango +
CZRANGEBYSCORE myset (mango +
DZRANGEBYLEX myset - (mango
What does the - symbol mean in ZRANGEBYLEX?
AInclude the member
BLargest possible member
CExclude the member
DSmallest possible member
If you want to include 'banana' in the range, which prefix do you use?
A[banana
B(banana
C-banana
D+banana
Can ZRANGEBYLEX return members sorted by their scores?
AYes, if you specify a score range
BYes, it sorts by score
CNo, it sorts by lexicographic order only
DNo, it returns random members
Explain how to use ZRANGEBYLEX to get members between two lexicographic values, including how to specify inclusive and exclusive ranges.
Think about how dictionary order works and how to include or exclude boundary words.
You got /4 concepts.
    Describe the difference between ZRANGEBYLEX and ZRANGEBYSCORE in Redis sorted sets.
    One sorts by words, the other by numbers.
    You got /4 concepts.