Redis String: INCRBY
Redis INCRBY Command
Redis INCRBY command is used to increment the number stored at key by specified value. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as an integer.
Here are some common uses and scenarios for the "INCRBY" command:
- Incremental Counting: Increment integers by a specified value (e.g., for counting).
- Batch Processing: Increase values of multiple keys by specified amounts efficiently.
- Rate Limiting: Track and enforce rate limits by incrementing values in controlled increments.
- Atomic Operations: Ensure atomicity when incrementing values in a multi-client environment.
- Data Aggregation: Aggregate data by adding values together for reporting or analysis.
Syntax:
INCRBY key increment
Available since
1.0.0.
Return Value
Integer reply, the value of key after the increment
Return Value Type
Integer
Example: Redis INCRBY
127.0.0.1:6379> SET visitors 1000 OK 127.0.0.1:6379> INCRBY visitors 10 (integer) 1010 127.0.0.1:6379> GET visitors "1010" 127.0.0.1:6379>
Previous:
INCR
Next:
INCRBYFLOAT
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-incrby-key-increment.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics