BF.ADD

Syntax
BF.ADD key item
Available in:
Redis Stack / Bloom 1.0.0
Time complexity:
O(k), where k is the number of hash functions used by the last sub-filter

Adds an item to a Bloom filter.

This command is similar to BF.MADD, except that only one item can be added.

Required arguments

key

is key name for a Bloom filter to add the item to.

If key does not exist - a new Bloom filter is created with default error rate, capacity, and expansion (see BF.RESERVE).

item

is an item to add.

Return value

Returns one of these replies:

  • Integer reply - where "1" means that the item has been added successfully, and "0" means that such item was already added to the filter (which could be wrong)
  • Error reply on error (invalid arguments, wrong key type, etc.) and also when the filter is full

Examples

redis> BF.ADD bf item1
(integer) 1
redis> BF.ADD bf item1
(integer) 0
Rate this page