blob: 36c0c7df00522124817443e660a5a4568df8ac34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
Removes the first `count` occurrences of elements equal to `element` from the list
stored at `key`.
The `count` argument influences the operation in the following ways:
* `count > 0`: Remove elements equal to `element` moving from head to tail.
* `count < 0`: Remove elements equal to `element` moving from tail to head.
* `count = 0`: Remove all elements equal to `element`.
For example, `LREM list -2 "hello"` will remove the last two occurrences of
`"hello"` in the list stored at `list`.
Note that non-existing keys are treated like empty lists, so when `key` does not
exist, the command will always return `0`.
@return
@integer-reply: the number of removed elements.
@examples
```cli
RPUSH mylist "hello"
RPUSH mylist "hello"
RPUSH mylist "foo"
RPUSH mylist "hello"
LREM mylist -2 "hello"
LRANGE mylist 0 -1
```
|