Redis LSET 命令将列表元素的索引值设置为该值,有关index参数的更多信息,请参见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"
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)