LREM key count value
Removes the first
count occurrences of elements equal to
value from the list
count argument influences the operation in the following ways:
count > 0: Remove elements equal to
valuemoving from head to tail.
count < 0: Remove elements equal to
valuemoving 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.
(integer) 1redis> RPUSH mylist “hello”
(integer) 2redis> RPUSH mylist “foo”
(integer) 3redis> RPUSH mylist “hello”
(integer) 4redis> LREM mylist -2 “hello”
(integer) 2redis> LRANGE mylist 0 -1
1) "hello" 2) "foo"