BF.RESERVE
BF.RESERVE key error_rate capacity [EXPANSION expansion] [NONSCALING]
- Group
- Bloom filter
- 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
BF.RESERVE creates an empty Bloom filter at key. A Bloom filter answers
“have I seen this item?” using far less memory than a set: it never misses an
item that was added, but may wrongly report an item that was not, at about
the error rate you choose.
You only need BF.RESERVE to pick non-default settings. BF.ADD,
BF.MADD and BF.INSERT create a
filter on demand, with capacity 100, error rate 0.01 and expansion 2.
Arguments and options
Section titled “Arguments and options”| Argument | Effect |
|---|---|
error_rate |
The false positive rate to aim for, between 0 and 1 (exclusive), for example 0.001 for 0.1%. Lower rates use more memory. |
capacity |
How many items the filter is sized for, from 1 to 1073741824. |
EXPANSION expansion |
When the filter is full, the next item adds a new layer this many times larger than the last one, keeping the overall error rate. Default 2, range 0 to 32768. 0 makes the filter non-scaling. |
NONSCALING |
Never grow: once capacity items are in, adding a new item fails. |
EXPANSION and NONSCALING cannot be combined. Other extra arguments are
ignored.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Created | Simple string OK |
Simple string OK |
Error replies:
ERR item existsif a Bloom filter already exists at the key.ERR bad error rateandERR error rate must be in the range (0.000000, 1.000000)ERR bad capacityandERR capacity must be in the range [1, 1073741824]ERR no expansion,ERR bad expansionandERR expansion must be in the range [0, 32768]Nonscaling filters cannot expandwhenEXPANSIONandNONSCALINGare both given.ERR Insufficient memory to create filterwhen the filter would not fit in memory.WRONGTYPEif the key holds another type.
Examples
Section titled “Examples”127.0.0.1:6379> BF.RESERVE signups 0.01 1000OK127.0.0.1:6379> BF.RESERVE signups 0.01 1000(error) ERR item exists127.0.0.1:6379> BF.RESERVE fixed 0.001 5000 NONSCALINGOK127.0.0.1:6379> BF.RESERVE bad 1.5 100(error) ERR error rate must be in the range (0.000000, 1.000000)Compatibility
Section titled “Compatibility”Same arguments, limits and errors as BF.RESERVE in RedisBloom.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.