HINCRBY - Increment a Hash's Field Value by a Specified Value in Redis

Feature thumb course thumb

Redis allows for quickly incrementing field values in a hash with the HINCRBY command. A few rules of this command are:

It has a complexity of O(1) It returns the value of the updated value of the field It takes three arguments: Hash name Field name The integer value that the field is going to be incremented by
127.0.0.1:6379> HINCRBY batting_order astros 1
(integer) 1
127.0.0.1:6379> HINCRBY batting_order rangers 1
(integer) 1
127.0.0.1:6379> HGET batting_order astros
"1"
127.0.0.1:6379> HINCRBY batting_order astros
(error) ERR wrong number of arguments for 'hincrby' command
127.0.0.1:6379> HINCRBY batting_order astros 1
(integer) 2
127.0.0.1:6379> HGET batting_order astros
"2"
127.0.0.1:6379> HINCRBY batting_order astros oops
(error) ERR value is not an integer or out of range