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.INITBYPROB

Last updated
CMS.INITBYPROB key error probability
Group
Count-min sketch
Complexity
O(1)
Arity
-1 (at least 1 words, counting the command name)
Flags
fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

CMS.INITBYPROB creates an empty Count-min sketch at key, sized so that an estimate overcounts by more than error times the total of all increments only with a chance of probability.

For example, error 0.001 and probability 0.01 mean: with 99% certainty, an item’s estimate is at most its true count plus 0.1% of everything counted.

The server derives the sketch’s width and depth from these values, the same way RedisBloom does. CMS.INFO shows the result.

Argument Meaning
error Allowed overcount, as a fraction of the total count. Between 0 and 1, exclusive.
probability Chance of exceeding that overcount. Between 0 and 1, exclusive.
Case RESP2 RESP3
Created Simple string OK Simple string OK

Error replies:

  • CMS: key already exists if the key exists (with any type).
  • CMS: invalid overestimation value and CMS: invalid prob value for values outside (0, 1).
  • CMS: Insufficient memory to create the key when the sketch would not fit in memory.
127.0.0.1:6379> CMS.INITBYPROB searches 0.001 0.01
OK
127.0.0.1:6379> CMS.INFO searches
1) width
2) (integer) 2000
3) depth
4) (integer) 7
5) count
6) (integer) 0
127.0.0.1:6379> CMS.INITBYPROB other 0 0.01
(error) CMS: invalid overestimation value

Same as CMS.INITBYPROB in RedisBloom, with the same dimensions for the same arguments.

CMS.INITBYDIM, CMS.INCRBY, CMS.INFO