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.ADD

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

Case RESP2 RESP3
Item added Integer 1 Boolean true
Item (probably) already present Integer 0 Boolean false

Error replies:

  • ERR non scaling filter is full when a non-scaling filter already holds its capacity.
  • ERR Insufficient memory to grow the filter or ERR Insufficient memory to create filter.
  • WRONGTYPE if the key holds another type.
127.0.0.1:6379> BF.ADD visitors alice
(integer) 1
127.0.0.1:6379> BF.ADD visitors alice
(integer) 0
127.0.0.1:6379> BF.EXISTS visitors alice
(integer) 1

Same as BF.ADD in RedisBloom, including the default filter settings.

BF.MADD, BF.INSERT, BF.EXISTS, BF.RESERVE, BF.CARD