List
LSET
Set a value at a specific index.
Arguments
keybodystrrequired
The key of the list.
indexbodynumberrequired
At which index to set the value.
elementbodystrrequired
The value to set.
Response
boolrequired
Returns True if the index was in range and the value was set.
Example
redis.rpush("mylist", "one", "two", "three")assert redis.lset("mylist", 1, "Hello") == Trueassert redis.lrange("mylist", 0, -1) == ["one", "Hello", "three"]assert redis.lset("mylist", 5, "Hello") == Falseassert redis.lrange("mylist", 0, -1) == ["one", "Hello", "three"]