0
0
Redisquery~10 mins

Why lists handle ordered sequences in Redis - Test Your Understanding

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
LPUSH mylist [1]
Drag options to blanks, or click blank then click option'
Aelement
Bmylist
CLPOP
DRPOP
Attempts:
3 left
💡 Hint
Common Mistakes
Using the list name instead of the element as the second argument.
Confusing LPUSH with LPOP or RPOP commands.
2fill in blank
medium

Complete the code to retrieve all elements from a Redis list.

Redis
LRANGE mylist [1] -1
Drag options to blanks, or click blank then click option'
A10
B-1
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using -1 as the start index, which returns an empty list.
Using 1 as the start index, which skips the first element.
3fill in blank
hard

Fix the error in the code to remove the last element from a Redis list.

Redis
[1] mylist
Drag options to blanks, or click blank then click option'
ALPOP
BRPOP
CLPUSH
DRPUSH
Attempts:
3 left
💡 Hint
Common Mistakes
Using LPUSH or RPUSH which add elements instead of removing.
Using LPOP which removes the first element, not the last.
4fill in blank
hard

Fill both blanks to add an element to the end and then get the last element from a Redis list.

Redis
RPUSH mylist [1]
[2] mylist
Drag options to blanks, or click blank then click option'
Aelement
BRPOP
CLPOP
Dmylist
Attempts:
3 left
💡 Hint
Common Mistakes
Using LPOP instead of RPOP to remove the last element.
Using the list name as the element to add.
5fill in blank
hard

Fill all three blanks to add an element to the start, get the first element, and remove it from a Redis list.

Redis
LPUSH mylist [1]
[2] mylist 0 0
[3] mylist
Drag options to blanks, or click blank then click option'
Aelement
BLRANGE
CLPOP
DRPUSH
Attempts:
3 left
💡 Hint
Common Mistakes
Using RPUSH instead of LPUSH to add to the start.
Using RPOP instead of LPOP to remove the first element.
Using LRANGE with wrong indexes.