What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.

BF.EXISTS

Determines if the bloom filter contains the specified item

Usage
BF.EXISTS key value
Complexity
O(N), where N is the number of hash functions used by the bloom filter.
Module
valkey-bloom
Since module version
1.0.0
ACL Categories
@read, @fast, @bloom

Determines if an item has been added to the bloom filter previously.

A bloom filter has two possible responses when you check if an item exists:

  • 0 - The item definitely does not exist since with bloom filters, false negatives are not possible.

  • 1 - The item exists with a given false positive (fp) percentage. There is an fp rate % chance that the item does not exist. You can create bloom filters with a more strict false positive rate as needed.

Examples

127.0.0.1:6379> BF.ADD key val
(integer) 1
127.0.0.1:6379> BF.EXISTS key val
(integer) 1
127.0.0.1:6379> BF.EXISTS key nonexistent
(integer) 0

Replies

RESP2

One of the following:

  • Integer reply: 1 if the item exists in the bloom filter
  • Integer reply: 0 if the bloom filter does not exist or the item has not been added to the bloom filter

RESP3

One of the following:

  • Integer reply: 1 if the item exists in the bloom filter
  • Integer reply: 0 if the bloom filter does not exist or the item has not been added to the bloom filter