LREM key count element
- Available since:
- Time complexity:
- O(N+M) where N is the length of the list and M is the number of elements removed.
- ACL categories:
Removes the first
count occurrences of elements equal to
element from the list
count argument influences the operation in the following ways:
count > 0: Remove elements equal to
elementmoving from head to tail.
count < 0: Remove elements equal to
elementmoving from tail to head.
count = 0: Remove all elements equal to
LREM list -2 "hello" will remove the last two occurrences of
"hello" in the list stored at
Note that non-existing keys are treated like empty lists, so when
key does not
exist, the command will always return
Integer reply: the number of removed elements.