Easy Tutorial
❮ Sorted Sets Zrevrank Server Lastsave ❯

Redis Decrby Command

Redis Strings

The Redis Decrby command subtracts the specified decrement value from the value stored in the key.

If the key does not exist, the key's value is initially set to 0 before performing the DECRBY operation.

If the value contains an incorrect type, or if the string value cannot be represented as a number, an error is returned.

The operation is limited to a 64-bit signed numeric representation.

Syntax

The basic syntax for the redis Decrby command is as follows:

redis 127.0.0.1:6379> DECRBY KEY_NAME DECREMENT_AMOUNT

Available Versions

= 1.0.0

Return Value

The value of the key after subtracting the specified decrement value.

Examples

# DECRBY on an existing key

redis> SET count 100
OK

redis> DECRBY count 20
(integer) 80

# DECRBY on a non-existing key

redis> EXISTS pages
(integer) 0

redis> DECRBY pages 10
(integer) -10

Redis Strings

❮ Sorted Sets Zrevrank Server Lastsave ❯