English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis Lset sets the value of an element by index.
Returns an error if the index parameter is out of range, or if LSET is called on an empty list.
For more information about list indices, please refer to LINDEX Command.
The basic syntax of the redis Lset command is as follows:
redis 127.0.0.1:6379> LSET KEY_NAME INDEX VALUE
>= 1.0.0
Operation successful returns ok, otherwise returns an error message.
redis 127.0.0.1:6379> RPUSH mylist "hello" (integer) 1 redis 127.0.0.1:6379> RPUSH mylist "hello" (integer) 2 redis 127.0.0.1:6379> RPUSH mylist "foo" (integer) 3 redis 127.0.0.1:6379> RPUSH mylist "hello" (integer) 4 redis 127.0.0.1:6379> LSET mylist 0 "bar" OK redis 127.0.0.1:6379> LRANGE mylist 0 -1 1: "bar" 2) "hello" 3) "foo" 4) "hello"