LSET

LSET

LSET key index element
Available since
1.0.0
Time complexity
O(N) where N is the length of the list. Setting either the first or the last element of the list is O(1).
ACL categories
@write, @list, @slow

Sets the list element at index to element. For more information on the index argument, see LINDEX.

An error is returned for out of range indexes.

Examples #

RPUSH mylist "one"
RPUSH mylist "two"
RPUSH mylist "three"
LSET mylist 0 "four"
LSET mylist -2 "five"
LRANGE mylist 0 -1

Redict logo courtesy of @janWilejan, CC-BY-SA-4.0. Download SVG ⤑

Portions of this website courtesy of Salvatore Sanfilippo, CC-BY-SA-4.0.