发布于 2015-06-22 09:01:11 | 112 次阅读 | 评论: 0 | 来源: 网络整理
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"