Complete the code to get the first 3 elements from the list 'mylist'.
LRANGE mylist 0 [1]
The LRANGE command uses zero-based indexes. To get the first 3 elements, the end index should be 2.
Complete the code to get the last 4 elements from the list 'tasks'.
LRANGE tasks [1] -1
Using a negative start index counts from the end. -4 means start from the 4th last element.
Fix the error in the code to get elements from index 2 to 5 in 'myqueue'.
LRANGE myqueue 2 [1]
The end index is inclusive, so to get elements from 2 to 5, use 5 as the end index.
Fill both blanks to get elements from the 3rd to the 7th position in 'events'.
LRANGE events [1] [2]
Indexes start at 0, so the 3rd position (1-based) is index 2 (A), 7th position is index 6 (C). End index is inclusive.
Fill all three blanks to get elements from index 1 to 4 from 'queue' and store in variable 'result'.
result = redis.call('LRANGE', 'queue', [1], [2]) -- expecting [3] elements
Start=1 (A), end=4 (B) inclusive returns 4 elements (C) at indices 1,2,3,4. Number = end - start + 1 = 4.