Database / ValKey Interview questions
What is the difference between LPUSH and RPUSH?
Both commands add one or more elements to a Valkey List, but at opposite ends of it.
RPUSH mylist "a" "b" "c" # list is now: [a, b, c] LPUSH mylist "x" # list is now: [x, a, b, c]
RPUSH appends at the tail (right), while LPUSH inserts at the head (left). Which one you use, paired with LPOP or RPOP, determines whether the list behaves like a FIFO queue or a LIFO stack.
More Related questions...