Easy Tutorial
❮ Hyperloglog Pfadd Redis Tutorial ❯

Redis Lrem Command

Redis Lists

Redis Lrem removes elements from the list that match the VALUE parameter, based on the COUNT parameter.

The COUNT value can be:

Syntax

The basic syntax for the redis Lrem command is as follows:

redis 127.0.0.1:6379> LREM key count VALUE

Available Versions

= 1.0.0

Return Value

The number of removed elements. Returns 0 if the list does not exist.

Example

redis> RPUSH mylist "hello"
(integer) 1
redis> RPUSH mylist "hello"
(integer) 2
redis> RPUSH mylist "foo"
(integer) 3
redis> RPUSH mylist "hello"
(integer) 4
redis> LREM mylist -2 "hello"
(integer) 2
redis> LRANGE mylist 0 -1
1) "hello"
2) "foo"
redis>

Redis Lists

❮ Hyperloglog Pfadd Redis Tutorial ❯