English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis DECRBY command subtracts the specified decrement amount from the value stored at the key.
If the key does not exist, the key's value will be initialized to 0 first, and then the DECRBY operation will be executed.
If the value contains an incorrect type, or if the string type value cannot be represented as a number, an error is returned.
The value of this operation is limited to 64 Within the range of signed numbers represented by bits.
Basic Syntax of Redis DECRBY Command
redis 127.0.0.1:6379> DECRBY KEY_NAME DECREMENT_AMOUNT
>= 1.0.0
The value of the key after subtracting the specified decrement amount.
# Decrement the value of an existing key redis> SET count 100 OK redis> DECRBY count 20 (integer) 80 # Decrement the value of a non-existing key redis> EXISTS pages (integer) 0 redis> DECRBY pages 10 (integer) -10