Advertisement
Intermediate Redis, RedisBloom (Probabilistic Data Structures)

Why can items not be removed from a standard Bloom filter, and what alternative structure does RedisBloom offer if you need removal support?

Short answer

A standard Bloom filter works by setting several bits shared across multiple items based on hash calculations, meaning you cannot safely clear those bits for one specific item without potentially affecting others, so RedisBloom also offers a Cuckoo filter, which uses a different…

Save Redis mock interview
Advertisement
AModel answer
A standard Bloom filter works by setting several bits shared across multiple items based on hash calculations, meaning you cannot safely clear those bits for one specific item without potentially affecting others, so RedisBloom also offers a Cuckoo filter, which uses a different internal approach that does support safely removing individual items when needed.
Example

CF.ADD my_cuckoo_filter 'item1' CF.DEL my_cuckoo_filter 'item1'

Real-world example
A content moderation system needing to both add and later remove flagged content identifiers chooses a Cuckoo filter over a standard Bloom filter specifically because it needs the ability to safely remove items when content is later approved.
Likely follow-ups
  • What are the tradeoffs between a Bloom filter and a Cuckoo filter in terms of memory usage?
  • When would you specifically need item removal capability in a real application?
Related topics