incr
increase increase; increase increase; increase increase; increase increase
by
英[ ba?] 美[ba?]
prep.beside...;expression method;due to;passing through
adv.passing;expressing retention or preservation; short visit
redis HINCRBY command syntax
Function: Add increment to the value of field field in hash table key.
Syntax: HINCRBY key field increment
Explanation: The increment can also be a negative number, which is equivalent to subtracting a given field. If key does not exist, a new hash table is created and the HINCRBY command is executed. If the field field does not exist, the value of the field is initialized to 0 before executing the command. Executing the HINCRBY command on a field that stores string values ??will cause an error. The value of this operation is limited to a 64-bit signed number representation.
Available versions: >= 2.0.0
Time complexity: O(1)
Return: After executing the HINCRBY command, the value of the field field in the hash table key.
redis HINCRBY command example
# increment 為正數(shù) redis> HEXISTS counter page_view # 對空域進(jìn)行設(shè)置 (integer) 0 redis> HINCRBY counter page_view 200 (integer) 200 redis> HGET counter page_view "200" # increment 為負(fù)數(shù) redis> HGET counter page_view "200" redis> HINCRBY counter page_view -50 (integer) 150 redis> HGET counter page_view "150" # 嘗試對字符串值的域執(zhí)行HINCRBY命令 redis> HSET myhash string hello,world # 設(shè)定一個字符串值 (integer) 1 redis> HGET myhash string "hello,world" redis> HINCRBY myhash string 1 # 命令執(zhí)行失敗,錯誤。 (error) ERR hash value is not an integer redis> HGET myhash string # 原值不變 "hello,world"