0
0
Redisquery~5 mins

LPUSH and RPUSH for insertion in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AInserts values at the end of a list
BDeletes values from a list
CInserts values at the beginning of a list
DCreates a new key without values
If you run LPUSH mylist "x" "y", what is the order of elements?
AEmpty list
B["x", "y"]
C["x"]
D["y", "x"]
What happens if the list key does not exist when using RPUSH?
AReturns an error
BCreates a new list with the values
CDoes nothing
DDeletes the key
Which command inserts values at the start of a list?
ALPUSH
BRPUSH
CLPOP
DRPOP
Can LPUSH and RPUSH insert multiple values at once?
AOnly RPUSH can
BNo
CYes
DOnly LPUSH can
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.