Redis Incrby 命令

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

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

如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCRBY 命令。

如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。

本操作的值限制在 64 位(bit)有符号数字表示之内。

语法

redis 127.0.0.1:6379> INCRBY KEY_NAME INCR_AMOUNT

返回值

加上指定的增量值之后, key 的值。

实例

实例1: key 已存在

127.0.0.1:6379> set domain 20
OK
127.0.0.1:6379> incrby domain 20
40
127.0.0.1:6379> get domain
40

实例2: key 已存在,但是值不是数字

127.0.0.1:6379> set domain www.codercto.com
OK
127.0.0.1:6379> incrby domain 20
ERR value is not an integer or out of range

实例3: key 不存在

127.0.0.1:6379> del domain
1
127.0.0.1:6379> incrby domain 20
20
127.0.0.1:6379> get domain
20

相关命令推荐

命令 描述
Redis Incr 命令 将 key 中储存的数字值增一。
Redis Incrbyfloat 命令 将 key 所储存的值加上给定的浮点增量值(increment) 。
Redis Decr 命令 将 key 中储存的数字值减一。
Redis Decrby 命令 key 所储存的值减去给定的减量值(decrement) 。

查看更多 Redis 字符串(String)命令

About Face 3

About Face 3

Alan Cooper、Robert Reimann、David Cronin / John Wiley & Sons / 2007-5-15 / GBP 28.99

* The return of the authoritative bestseller includes all new content relevant to the popularization of how About Face maintains its relevance to new Web technologies such as AJAX and mobile platforms......一起来看看 《About Face 3》 这本书的介绍吧!

RGB转16进制工具

RGB转16进制工具

RGB HEX 互转工具

UNIX 时间戳转换

UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具

HSV CMYK 转换工具

HSV CMYK互换工具