0
0
Redisquery~10 mins

List vs sorted set for sequences in Redis - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add an element to the end of a Redis list.

Redis
redis-cli RPUSH mylist [1]
Drag options to blanks, or click blank then click option'
Aelement
Bmylist
CZADD
DSADD
Attempts:
3 left
💡 Hint
Common Mistakes
Using the list name instead of the element as the second argument.
Confusing RPUSH with ZADD or SADD commands.
2fill in blank
medium

Complete the code to add an element with a score to a Redis sorted set.

Redis
redis-cli ZADD myzset [1] element
Drag options to blanks, or click blank then click option'
Ascore
BZREM
Cmyzset
Delement
Attempts:
3 left
💡 Hint
Common Mistakes
Using the element name instead of the score.
Confusing ZADD with ZREM or other commands.
3fill in blank
hard

Fix the error in the command to get the first 3 elements from a Redis list.

Redis
redis-cli LRANGE mylist [1] 2
Drag options to blanks, or click blank then click option'
A-1
B0
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Starting at 1 instead of 0, which skips the first element.
Using 3 as start index which is out of range.
4fill in blank
hard

Fill both blanks to retrieve elements with scores between 10 and 20 from a sorted set.

Redis
redis-cli ZRANGEBYSCORE myzset [1] [2]
Drag options to blanks, or click blank then click option'
A10
B20
C-inf
D+inf
Attempts:
3 left
💡 Hint
Common Mistakes
Using -inf or +inf instead of specific score values.
Swapping min and max values.
5fill in blank
hard

Fill all three blanks to add an element with score 15 and then retrieve elements with scores between 10 and 20.

Redis
redis-cli [1] myzset [2] element && redis-cli ZRANGEBYSCORE myzset 10 20
Drag options to blanks, or click blank then click option'
AZADD
B15
Cmyzset
DSADD
Attempts:
3 left
💡 Hint
Common Mistakes
Using SADD instead of ZADD for sorted sets.
Mixing up the order of arguments.