Redis Lists: LSET
LSET key index value
Redis LSET command is used to set the list element at index to value. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list.
Syntax:
LSET KEY_NAME INDEX VALUE
Available since
1.0.0.
Return Value
String reply, OK
Return Value Type
String
Example: Redis LSET
127.0.0.1:6379> LPUSH mycolor1 white black red blue (integer) 4 127.0.0.1:6379> LRANGE mycolor1 0 -1 1) "blue" 2) "red" 3) "black" 4) "white" 127.0.0.1:6379> LSET mycolor1 2 YELLOW OK 127.0.0.1:6379> LSET mycolor1 -1 GREEN OK 127.0.0.1:6379> LRANGE mycolor1 0 -1 1) "blue" 2) "red" 3) "YELLOW" 4) "GREEN" 127.0.0.1:6379> LSET mycolor 2 YELLOW (error) ERR index out of range
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics