Redis LSET命令
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"