0
0
Redisquery~10 mins

LRANGE for reading elements in Redis - Interactive Code Practice

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

Complete the code to get the first 3 elements from the list 'mylist'.

Redis
LRANGE mylist 0 [1]
Drag options to blanks, or click blank then click option'
A2
B3
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as the end index returns 4 elements.
Using -1 returns the entire list.
2fill in blank
medium

Complete the code to get the last 4 elements from the list 'tasks'.

Redis
LRANGE tasks [1] -1
Drag options to blanks, or click blank then click option'
A4
B-4
C-3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 4 as start index skips first 4 elements instead of last 4.
Using -3 returns only last 3 elements.
3fill in blank
hard

Fix the error in the code to get elements from index 2 to 5 in 'myqueue'.

Redis
LRANGE myqueue 2 [1]
Drag options to blanks, or click blank then click option'
A6
B-1
C5
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 6 returns one extra element.
Using 4 returns one less element.
4fill in blank
hard

Fill both blanks to get elements from the 3rd to the 7th position in 'events'.

Redis
LRANGE events [1] [2]
Drag options to blanks, or click blank then click option'
A2
B3
C6
D7
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 (B) as start index gets from 4th position.
Using 7 (D) as end index gets up to 8th position.
5fill in blank
hard

Fill all three blanks to get elements from index 1 to 4 from 'queue' and store in variable 'result'.

Redis
result = redis.call('LRANGE', 'queue', [1], [2]) -- expecting [3] elements
Drag options to blanks, or click blank then click option'
A1
B4
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Expecting 3 elements instead of 4.
Using wrong start or end indexes.