LSET key index value

自1.0.0版本可用 时间复杂度:O(N) N是list的长度,设置第一个或最后一个元素的时间复杂度为O(1)

设置指定元素索引的值。获取更多关于index参数的信息,请看LINDEX 如果索引越界会返回一个错误

返回值

返回简单的字符串

示例

redis> RPUSH mylist "one"
(integer) 1
redis> RPUSH mylist "two"
(integer) 2
redis> RPUSH mylist "three"
(integer) 3
redis> LSET mylist 0 "four"
"ok"
redis> LSET mylist -2 "five"
"ok"
redis>LRANGE mylist 0 -1
1) "four"
2) "five"
3) "three"

results matching ""

    No results matching ""