BF.INSERT
BF.INSERT key [CAPACITY capacity] [ERROR error] [EXPANSION expansion] [NOCREATE] [NONSCALING] ITEMS item [item ...]
- Group
- Bloom filter
- Complexity
- O(k * n), k hash functions and n 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
BF.INSERT adds items to the Bloom filter at key like
BF.MADD, but lets you set how a missing filter is
created, or forbid creating it. The settings only apply when the filter is
created by this call; an existing filter keeps its own.
Options
Section titled “Options”| Option | Effect |
|---|---|
CAPACITY capacity |
Capacity of a new filter, 1 to 1073741824 (default 100). |
ERROR error |
Error rate of a new filter, between 0 and 1 exclusive (default 0.01). |
EXPANSION expansion |
Growth factor of a new filter, 0 to 32768 (default 2). |
NONSCALING |
Make a new filter non-scaling. |
NOCREATE |
Do not create the filter: reply ERR not found if the key does not exist. |
ITEMS item [item ...] |
The items to add. Required, and must come last. |
Return value
Section titled “Return value”An array with one element per item, as for BF.MADD:
| Element | RESP2 | RESP3 |
|---|---|---|
| Item added | Integer 1 |
Boolean true |
| Item (probably) already present | Integer 0 |
Boolean false |
If an item cannot be added, the array ends with that error
(ERR non scaling filter is full or ERR Insufficient memory to grow the filter)
and the remaining items are not tried.
Error replies for the whole call:
ERR not foundwithNOCREATEand no filter at the key.Bad capacity,Bad error rate,Bad expansionfor invalid option values.Unknown argument receivedfor an unknown option beforeITEMS.ERR wrong number of arguments for 'bf.insert' commandwhenITEMSor the items are missing.ERR Insufficient memory to create filter, orWRONGTYPE.
Examples
Section titled “Examples”127.0.0.1:6379> BF.INSERT emails CAPACITY 10000 ERROR 0.001 ITEMS a@example.com b@example.com1) (integer) 12) (integer) 1127.0.0.1:6379> BF.INSERT emails ITEMS a@example.com1) (integer) 0127.0.0.1:6379> BF.INSERT other NOCREATE ITEMS x(error) ERR not foundCompatibility
Section titled “Compatibility”Same as BF.INSERT in RedisBloom.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.