Redis LSET命令将在索引值的列表元素。有关索引参数的详细信息,请参阅LINDEX。超出索引的范围返回一个错误。
返回值
返回字符串:Ok
实例
redis LSET命令的基本语法如下所示:
redis 127.0.0.1:6379> LSET KEY_NAME INDEX VALUE
例子
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"