List

LTRIM

Trim a list to the specified range

Arguments

keybodystrrequired

The key of the list.

startbodyintrequired

The index of the first element to keep.

stopbodyintrequired

The index of the first element to keep.

Response

boolrequired

Returns True if the list was trimmed, False otherwise.

Example
redis.rpush("mylist", "one", "two", "three")assert redis.ltrim("mylist", 0, 1) == Trueassert redis.lrange("mylist", 0, -1) == ["one", "two"]
Loading search…