Redis Commands
- A
- B
- Client
-
Cluster
- Cluster-addslots
- Cluster-addslotsrange
- Cluster-bumpepoch
- Cluster-count-failure-reports
- Cluster-countkeysinslot
- Cluster-delslots
- Cluster-delslotsrange
- Cluster-failover
- Cluster-flushslots
- Cluster-forget
- Cluster-getkeysinslot
- Cluster-help
- Cluster-info
- Cluster-keyslot
- Cluster-links
- Cluster-meet
- Cluster-myid
- Cluster-myshardid
- Cluster-nodes
- Cluster-replicas
- Cluster-replicate
- Cluster-reset
- Cluster-saveconfig
- Cluster-set-config-epoch
- Cluster-setslot
- Cluster-shards
- Cluster-slaves
- Cluster-slots
- Cluster
- Command
- Config
- D
- E
- F
- G
- H
- I
- K
- L
- M
- O
- P
- Q
- R
- S1
- S2
- T
- U
- W
- X
- Z1
- Z2
Docs > Redis Commands > L > Lrem
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 toelement
moving from head to tail.count < 0
: Remove elements equal toelement
moving from tail to head.count = 0
: Remove all elements equal toelement
.
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
RPUSH mylist "hello"
RPUSH mylist "hello"
RPUSH mylist "foo"
RPUSH mylist "hello"
LREM mylist -2 "hello"
LRANGE mylist 0 -1