Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

CMS.INCRBY

Last updated
CMS.INCRBY key item increment [item increment ...]
Group
Count-min sketch
Complexity
O(n * depth), n being the items
Arity
-1 (at least 1 words, counting the command name)
Flags
none
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

CMS.INCRBY adds increment to the count of each item in the Count-min sketch at key, and returns each item’s estimated count afterwards. The sketch must exist: create it with CMS.INITBYDIM or CMS.INITBYPROB.

Increments must be whole numbers of 0 or more. All of them are checked before anything is counted, so one bad increment changes nothing. Counts stop at 4294967295.

An array with one integer per item: its estimated count after the increment. The shape is the same in RESP2 and RESP3.

If an item’s count would go past 4294967295, its element is the error CMS: INCRBY overflow instead.

Error replies for the whole call:

  • CMS: key does not exist
  • CMS: Cannot parse number for an increment that is not an integer.
  • CMS: Number cannot be negative
  • ERR wrong number of arguments for 'cms.incrby' command for unpaired arguments.
  • WRONGTYPE if the key holds another type.
127.0.0.1:6379> CMS.INITBYDIM pageviews 2000 5
OK
127.0.0.1:6379> CMS.INCRBY pageviews /home 3 /pricing 1
1) (integer) 3
2) (integer) 1
127.0.0.1:6379> CMS.INCRBY pageviews /home 2
1) (integer) 5
127.0.0.1:6379> CMS.INCRBY pageviews /home -1
(error) CMS: Number cannot be negative

Same as CMS.INCRBY in RedisBloom. HotKV checks every increment before counting any, so a bad increment leaves the sketch unchanged.

CMS.QUERY, CMS.INITBYDIM, CMS.MERGE