English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis Decr command will subtract one from the numeric value stored in the key.
If the key does not exist, the key's value will be initialized to 0 first, and then the DECR 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 Signed numbers within the range of bit (bit)
The basic syntax of the Redis Decr command is as follows:
redis 127.0.0.1:6379> DECR KEY_NAME
>= 1.0.0
The value of the key after executing the command.
# DECR for existing numeric value keys redis> SET failure_times 10 OK redis> DECR failure_times (integer) 9 # DECR for non-existent key values redis> EXISTS count (integer) 0 redis> DECR count (integer) -1 # DECR for keys that exist but are not numeric redis> SET company YOUR_CODE_SUCKS.LLC OK redis> DECR company (error) ERR value is not an integer or out of range