LSET

Syntax
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

redis> RPUSH mylist "one"
(integer) 11
redis> RPUSH mylist "two"
(integer) 6
redis> RPUSH mylist "three"
1) (integer) 8
2) (integer) 9
3) (integer) 10
redis> RPUSH mylist "one"
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> RPUSH mylist "two"
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> RPUSH mylist "three"
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> LSET mylist 0 "four"
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> LSET mylist -2 "five"
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> LRANGE mylist 0 -1
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis>

RESP2/RESP3 Reply

Simple string reply: OK.
RATE THIS PAGE
Back to top ↑