English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis Lrem removes elements equal to the parameter VALUE from the list according to the parameter COUNT.
The value of COUNT can be one of the following types:
count > 0 : Start from the head of the table and search towards the end, remove elements equal to VALUE, the number of elements to remove is COUNT.
count < 0 : Start from the end of the table and search towards the head, remove elements equal to VALUE, the number of elements to remove is the absolute value of COUNT.
count = 0 : Remove all values equal to VALUE in the table.
Basic Syntax of Redis Lrem Command
redis 127.0.0.1:6379> LREM key count VALUE
>= 1.0.0
The number of elements removed. Returns 0 when the list does not exist.
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>