YouTip LogoYouTip

Strings Decr

# Redis Decr Command [!(#) Redis Strings](#) The Redis Decr command decrements the numerical value stored in a key by one. If the key does not exist, the key's value will be initialized to 0 first, and then the DECR operation will be performed. If the value contains an incorrect type, or if a string value cannot be represented as a number, an error is returned. The value of this operation is limited within the 64-bit signed integer representation. ### Syntax The basic syntax of the redis Decr command is as follows: redis 127.0.0.1:6379> DECR KEY_NAME ### Available Version >= 1.0.0 ### Return Value The value of the key after executing the command. ### Example # Decrement an existing numeric key value redis> SET failure_times 10 OK redis> DECR failure_times (integer) 9# Decrement a non-existent key value redis> EXISTS count (integer)between 0 redis> DECR count (integer) -1# Attempt to decrement a key that exists but is not a numeric value redis> SET company YOUR_CODE_SUCKS.LLC OK redis> DECR company (error) ERR value is not an integer or out of range [!(#) Redis Strings](#)
← Strings DecrbyStrings Incrbyfloat β†’