LTRIM

Since 1.1.0Lists

Syntax

LTRIM key start stop
  • Flags: write
  • ACL categories: @list, @slow, @write
  • Arity: 4

Keeps only the elements from index start to index stop, both included, and removes the rest. Negative indexes count from the end. A range outside the list leaves it empty, and the key is deleted.

Reply

  • OK.

Examples

> RPUSH t a b c d e
(integer) 5
> LTRIM t 1 3
OK
> LRANGE t 0 -1
1) "b"
2) "c"
3) "d"