CMS.INCRBY
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.
Return value
Section titled “Return value”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 existCMS: Cannot parse numberfor an increment that is not an integer.CMS: Number cannot be negativeERR wrong number of arguments for 'cms.incrby' commandfor unpaired arguments.WRONGTYPEif the key holds another type.
Examples
Section titled “Examples”127.0.0.1:6379> CMS.INITBYDIM pageviews 2000 5OK127.0.0.1:6379> CMS.INCRBY pageviews /home 3 /pricing 11) (integer) 32) (integer) 1127.0.0.1:6379> CMS.INCRBY pageviews /home 21) (integer) 5127.0.0.1:6379> CMS.INCRBY pageviews /home -1(error) CMS: Number cannot be negativeCompatibility
Section titled “Compatibility”Same as CMS.INCRBY in RedisBloom. HotKV checks every increment before
counting any, so a bad increment leaves the sketch unchanged.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.