Redis Decrby 命令

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

Redis Decrby 命令将 key 所储存的值减去指定的减量值。

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

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

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

语法

redis 127.0.0.1:6379> DECRBY KEY_NAME DECREMENT_AMOUNT

返回值

减去指定减量值之后, key 的值。

实例

实例1:key 存在

127.0.0.1:6379> set codercto 200
OK
127.0.0.1:6379> decrby codercto 20
180

实例2:key 不存在

127.0.0.1:6379> del codercto
1
127.0.0.1:6379> decrby codercto 20
-20
127.0.0.1:6379> get codercto
-20

相关命令推荐

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

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

Chinese Authoritarianism in the Information Age

Chinese Authoritarianism in the Information Age

Routledge / 2018-2-13 / GBP 115.00

This book examines information and public opinion control by the authoritarian state in response to popular access to information and upgraded political communication channels among the citizens in co......一起来看看 《Chinese Authoritarianism in the Information Age》 这本书的介绍吧!

MD5 加密

MD5 加密

MD5 加密工具

html转js在线工具

html转js在线工具

html转js在线工具

HSV CMYK 转换工具

HSV CMYK 转换工具

HSV CMYK互换工具