Recall & Review
beginner
What does the LREM command do in Redis?
LREM removes elements from a list that match a given value. You specify how many matching elements to remove and the value to remove.
Click to reveal answer
intermediate
How does the count parameter affect the LREM command?
The count parameter controls how many matching elements to remove: positive count removes from head to tail, negative count removes from tail to head, zero removes all matching elements.
Click to reveal answer
beginner
Syntax of the LREM command?
LREM key count value
Example: LREM mylist 2 "apple" removes up to 2 occurrences of "apple" from the list named mylist.
Click to reveal answer
beginner
What happens if count is zero in LREM?
If count is zero, LREM removes all elements equal to the given value from the list.
Click to reveal answer
beginner
Can LREM remove elements that do not exist in the list?
No, LREM only removes elements that match the value. If no elements match, the list remains unchanged and the command returns 0.
Click to reveal answer
What does LREM mylist 3 "orange" do?
✗ Incorrect
LREM with positive count removes up to that many matching elements from head to tail.
What does LREM mylist -2 "banana" do?
✗ Incorrect
Negative count removes matching elements starting from the tail.
If count is zero in LREM, what happens?
✗ Incorrect
Count zero means remove all matching elements.
What does LREM return?
✗ Incorrect
LREM returns how many elements it removed.
If the value does not exist in the list, what does LREM do?
✗ Incorrect
If no matching elements exist, LREM does nothing and returns 0.
Explain how the count parameter affects the behavior of the LREM command in Redis.
Think about direction and how many elements are removed.
You got /3 concepts.
Describe a real-life example where you might use LREM to remove elements from a Redis list.
Imagine a list of things you want to update by removing some items.
You got /3 concepts.