CMS.INITBYPROB
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.
Arguments
Section titled “Arguments”| 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. |
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Created | Simple string OK |
Simple string OK |
Error replies:
CMS: key already existsif the key exists (with any type).CMS: invalid overestimation valueandCMS: invalid prob valuefor values outside (0, 1).CMS: Insufficient memory to create the keywhen the sketch would not fit in memory.
Examples
Section titled “Examples”127.0.0.1:6379> CMS.INITBYPROB searches 0.001 0.01OK127.0.0.1:6379> CMS.INFO searches1) width2) (integer) 20003) depth4) (integer) 75) count6) (integer) 0127.0.0.1:6379> CMS.INITBYPROB other 0 0.01(error) CMS: invalid overestimation valueCompatibility
Section titled “Compatibility”Same as CMS.INITBYPROB in RedisBloom, with the same dimensions for the same
arguments.
See also
Section titled “See also”Was this helpful?
Thanks for the feedback.