Back to Redis

HINCRBY

content/commands/hincrby.md

latest1.4 KB
Original Source

Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.

The range of values supported by HINCRBY is limited to 64 bit signed integers.

Examples

Since the increment argument is signed, both increment and decrement operations can be performed:

{{% redis-cli %}} HSET myhash field 5 HINCRBY myhash field 1 HINCRBY myhash field -1 HINCRBY myhash field -10 {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="hincrby-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: the value of the field after the increment operation.

-tab-sep-

Integer reply: the value of the field after the increment operation.

{{< /multitabs >}}