YouTip LogoYouTip

Strings Incrby

# Redis Incrby Command [!(#) Redis Strings](#) The Redis `INCRBY` command increments the number stored at `key` by the specified increment. If the `key` does not exist, it is set to `0` before performing the `INCRBY` operation. If the value contains an incorrect type, or if the string value cannot be represented as a number, an error is returned. The value for this operation is limited to the range of a signed 64-bit integer. ### Syntax The basic syntax of the Redis `INCRBY` command is as follows: redis 127.0.0.1:6379> INCRBY KEY_NAME INCR_AMOUNT ### Available since >= 1.0.0 ### Return Value The value of `key` after incrementing by the specified amount. ### Example # key exists and holds a numeric value redis> SET rank 50 OK redis> INCRBY rank 20(integer) 70 redis> GET rank "70"# key does not exist redis> EXISTS counter (integer) 0 redis> INCRBY counter 30(integer) 30 redis> GET counter "30"# key does not hold a numeric value redis> SET book "long long ago..." OK redis> INCRBY book 200(error) ERR value is not an integer or out of range [!(#) Redis Strings](#)
← Strings IncrbyfloatStrings Incr β†’