Redis Lset 命令

更新时间: 2019-07-07 15:54

Redis Lset 通过索引来设置元素的值。

当索引参数超出范围,或对一个空列表进行 LSET 时,返回一个错误。

关于列表下标的更多信息,请参考 LINDEX 命令

语法

redis 127.0.0.1:6379> LSET KEY_NAME INDEX VALUE

返回值

操作成功返回 ok ,否则返回错误信息。

实例

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"

查看更多 Redis 列表(List)命令

Programming Collective Intelligence

Programming Collective Intelligence

Toby Segaran / O'Reilly Media / 2007-8-26 / USD 39.99

Want to tap the power behind search rankings, product recommendations, social bookmarking, and online matchmaking? This fascinating book demonstrates how you can build Web 2.0 applications to mine the......一起来看看 《Programming Collective Intelligence》 这本书的介绍吧!

XML、JSON 在线转换

XML、JSON 在线转换

在线XML、JSON转换工具

RGB HSV 转换

RGB HSV 转换

RGB HSV 互转工具

HSV CMYK 转换工具

HSV CMYK 转换工具

HSV CMYK互换工具