美文网首页
Redis Incrby 命令将 key 中储存的数字加上指定的

Redis Incrby 命令将 key 中储存的数字加上指定的

作者: 陆遥远 | 来源:发表于2018-07-10 23:15 被阅读0次
# key 存在且是数字值

redis> SET rank 50
OK

redis> INCRBY rank 20
(integer) 70

redis> GET rank
"70"


# key 不存在时

redis> EXISTS counter
(integer) 0

redis> INCRBY counter 30
(integer) 30

redis> GET counter
"30"


# key 不是数字值时

redis> SET book "long long ago..."
OK

redis> INCRBY book 200
(error) ERR value is not an integer or out of range

相关文章

网友评论

      本文标题:Redis Incrby 命令将 key 中储存的数字加上指定的

      本文链接:https://www.haomeiwen.com/subject/taccpftx.html