BF.ADD
BF.ADD key item
- Group
- Bloom filter
- Complexity
- O(k), k being the number of hash functions
- 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
BF.ADD adds item to the Bloom filter at key. If the key does not exist,
a filter is created first with capacity 100, error rate 0.01 and expansion 2.
Use BF.RESERVE or BF.INSERT
for other settings.
The reply tells you whether the item is new. Because Bloom filters can give false positives, a new item is occasionally reported as already present.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Item added | Integer 1 |
Boolean true |
| Item (probably) already present | Integer 0 |
Boolean false |
Error replies:
ERR non scaling filter is fullwhen a non-scaling filter already holds its capacity.ERR Insufficient memory to grow the filterorERR Insufficient memory to create filter.WRONGTYPEif the key holds another type.
Examples
Section titled “Examples”127.0.0.1:6379> BF.ADD visitors alice(integer) 1127.0.0.1:6379> BF.ADD visitors alice(integer) 0127.0.0.1:6379> BF.EXISTS visitors alice(integer) 1Compatibility
Section titled “Compatibility”Same as BF.ADD in RedisBloom, including the default filter settings.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.