0
0
Redisquery~10 mins

LTRIM for list capping 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 trim the list 'mylist' to keep only the first 100 elements.

Redis
LTRIM mylist 0 [1]
Drag options to blanks, or click blank then click option'
A101
B100
C-1
D99
Attempts:
3 left
💡 Hint
Common Mistakes
Using 100 as the end index which keeps 101 elements.
Using negative indexes incorrectly.
2fill in blank
medium

Complete the code to keep only the last 50 elements of the list 'events'.

Redis
LTRIM events [1] -1
Drag options to blanks, or click blank then click option'
A-49
B0
C-50
D49
Attempts:
3 left
💡 Hint
Common Mistakes
Using -50 as start index which keeps 51 elements.
Using positive indexes which may not keep last elements.
3fill in blank
hard

Fix the error in the command to keep only the first 10 elements of 'tasks'.

Redis
LTRIM tasks 0 [1]
Drag options to blanks, or click blank then click option'
A10
B-10
C9
D-9
Attempts:
3 left
💡 Hint
Common Mistakes
Using 10 as end index which keeps 11 elements.
Using negative indexes incorrectly.
4fill in blank
hard

Fill both blanks to trim 'logs' list to keep elements from index 5 to 15.

Redis
LTRIM logs [1] [2]
Drag options to blanks, or click blank then click option'
A5
B15
C10
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping start and end indexes.
Using indexes outside the list range.
5fill in blank
hard

Fill all three blanks to trim 'queue' list to keep elements from index 2 to 12.

Redis
LTRIM [1] [2] [3]
Drag options to blanks, or click blank then click option'
Aqueue
B2
C12
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong list name.
Incorrect start or end indexes.