Recall & Review
beginner
What does the LPUSH command do in Redis?
LPUSH inserts one or more values at the beginning (left) of a list stored at a given key.
Click to reveal answer
beginner
How does RPUSH differ from LPUSH in Redis?
RPUSH inserts one or more values at the end (right) of a list, while LPUSH inserts at the beginning (left).
Click to reveal answer
intermediate
If you run LPUSH mylist "a" "b" "c", what will be the order of elements in the list?
The list will be ["c", "b", "a"] because LPUSH inserts each new element at the front, so the last value ends up first.
Click to reveal answer
beginner
What happens if the key does not exist when you use LPUSH or RPUSH?
Redis creates a new list with the given values if the key does not exist.
Click to reveal answer
beginner
Can LPUSH and RPUSH be used to insert multiple values at once?
Yes, both commands accept multiple values and insert them in the order given.
Click to reveal answer
What does RPUSH do in Redis?
✗ Incorrect
RPUSH adds one or more values to the end (right side) of a list.
If you run LPUSH mylist "x" "y", what is the order of elements?
✗ Incorrect
LPUSH inserts each value at the front, so the last value ends up first.
What happens if the list key does not exist when using RPUSH?
✗ Incorrect
Redis creates a new list with the given values if the key does not exist.
Which command inserts values at the start of a list?
✗ Incorrect
LPUSH inserts values at the beginning (left) of the list.
Can LPUSH and RPUSH insert multiple values at once?
✗ Incorrect
Both LPUSH and RPUSH accept multiple values and insert them in order.
Explain how LPUSH and RPUSH work for inserting elements into a Redis list.
Think about left and right ends of a list.
You got /4 concepts.
Describe the order of elements after using LPUSH with multiple values.
Imagine stacking plates on top.
You got /3 concepts.