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.

BF.INSERT

Last updated
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.

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.

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 found with NOCREATE and no filter at the key.
  • Bad capacity, Bad error rate, Bad expansion for invalid option values.
  • Unknown argument received for an unknown option before ITEMS.
  • ERR wrong number of arguments for 'bf.insert' command when ITEMS or the items are missing.
  • ERR Insufficient memory to create filter, or WRONGTYPE.
127.0.0.1:6379> BF.INSERT emails CAPACITY 10000 ERROR 0.001 ITEMS a@example.com b@example.com
1) (integer) 1
2) (integer) 1
127.0.0.1:6379> BF.INSERT emails ITEMS a@example.com
1) (integer) 0
127.0.0.1:6379> BF.INSERT other NOCREATE ITEMS x
(error) ERR not found

Same as BF.INSERT in RedisBloom.

BF.MADD, BF.RESERVE, BF.ADD