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 INCRBY command syntax
Function: Add increment to the value stored in key.
Syntax: INCRBY key increment
Description: If key does not exist, then the value of key will be initialized to 0 first, and then executed INCRBY command. If the value contains the wrong type, or a value of type string cannot be represented as a number, an error is returned. The value of this operation is limited to 64-bit signed number representation.
Available versions: >= 1.0.0
Time complexity: O(1)
Return: After adding increment, the value of key.
redis INCRBY command example
# key 存在且是数字值 redis> SET rank 50 OK redis> INCRBY rank 20 (integer) 70 redis> GET rank "70" # key 不存在时 redis> EXISTS counter (integer) 0 redis> INCRBY counter 30 (integer) 30 redis> GET counter "30" # key 不是数字值时 redis> SET book "long long ago..." OK redis> INCRBY book 200 (error) ERR value is not an integer or out of range