Latest web development tutorials

Redis Decrby command

Redis string (string)

Redis Decrby command key stored value minus the specified value reductions.

If the key is not present, then the value of the key will first be initialized to 0, and then execute DECRBY operation.

If the value type or string type containing the error can not be expressed as a number, it returns an error.

This operation is limited to the value of 64-bit (bit) signed within the digital representation.

grammar

redis Decrby basic command syntax is as follows:

redis 127.0.0.1:6379> DECRBY KEY_NAME DECREMENT_AMOUNT

Available versions

> = 1.0.0

return value

After subtracting the value of the specified reductions, key values.

Examples

# 对已存在的 key 进行 DECRBY

redis> SET count 100
OK

redis> DECRBY count 20
(integer) 80


# 对不存在的 key 进行DECRBY

redis> EXISTS pages
(integer) 0

redis> DECRBY pages 10
(integer) -10

Redis string (string)