HINCRBY

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

Synopsis

HINCRBY key field deltaThis command adds delta to the number that is associated with the given field field for the hash key. The numeric value must a 64-bit signed integer.

  • If the key does not exist, a new hash container is created. If the field field does not exist in the hash container, the associated string is set to “0”.
  • If the given key is not associated with a hash type, or if the string associated with field cannot be converted to an integer, an error is raised.

Return Value

Returns the value after addition.

Examples

You can do this as shown below.

  1. $ HSET yugahash f1 5
  1. 1
  1. $ HINCRBY yugahash f1 3
  1. 8
  1. $ HINCRBY yugahash non-existent-f2 4
  1. 4
  1. $ HINCRBY non-existent-yugahash f1 3
  1. 3

See Also

hexists, hget, hgetall, hkeys, hlen, hmget, hmset, hset, hincrby, hstrlen, hvals