LREM

Since 1.1.0Lists

Syntax

LREM key count element
  • Flags: write
  • ACL categories: @list, @slow, @write
  • Arity: 4

Removes elements equal to element from the list at key:

  • count greater than 0: the first count of them, from the head;
  • count less than 0: the last -count of them, from the tail;
  • count 0: all of them.

Reply

  • The number of elements removed.

Examples

> RPUSH r a b a c a
(integer) 5
> LREM r 2 a
(integer) 2
> LRANGE r 0 -1
1) "b"
2) "c"
3) "a"
> RPUSH r2 a b a c a
(integer) 5
> LREM r2 -1 a
(integer) 1