BF.ADD my_filter 'user123'
BF.EXISTS my_filter 'user123'
Topics
40
Caching Patterns
Cluster Sharding & Hash Slots
Clustering
Connection Pooling & Client Libraries
Data Types
Distributed Locks with Redis
Expiration & Eviction
Geospatial Data in Redis
Hashes in Redis
HyperLogLog in Redis
Keyspace Notifications
Leaderboards with Sorted Sets
Lists in Redis
Lua Scripting
Persistence (RDB/AOF)
Pub/Sub
Rate Limiting with Redis
Redis Architecture & Installation
Redis as a Message Queue
Redis Backup & Disaster Recovery
Redis CLI & Basic Commands
Redis Memory Optimization
Redis Modules Overview
Redis Monitoring & Observability
Redis Performance Tuning & Benchmarking
Redis Replication
Redis Security & ACL
Redis Sentinel & High Availability
Redis vs Memcached
Redis with Docker & Kubernetes
RedisBloom (Probabilistic Data Structures)
RedisJSON
RedisSearch (Full Text Search)
RedisTimeSeries
Session Management with Redis
Sets & Sorted Sets in Redis
Streams
Strings & Bitmaps in Redis
TLS & Encryption in Redis
Transactions
RedisBloom (Probabilistic Data Structures)
7 questions found
A Bloom filter is a highly memory efficient probabilistic data structure that can quickly tell you whether an item is definitely not in a set or possibly in a set, and RedisBloom adds this capability to Redis, letting you check for likely membership in a very large collection using far less memory than storing every actual item.
Real-world example
A web crawler uses a Bloom filter to quickly check whether it has already visited a specific URL before, avoiding the need to store and search through billions of actual URL strings just to prevent revisiting the same pages.
HyperLogLog in Redis;Redis Modules Overview
How do you add items to a Bloom filter and check if an item might already exist using RedisBloom commands?
BeginnerYou use BF.ADD to add an item to a Bloom filter, automatically creating the filter if it does not already exist, and BF.EXISTS to check whether an item has possibly already been added, returning a definite no if the item was certainly never added, or a probable yes that could occasionally be a false positive.
BF.ADD visited_urls 'https://example.com/page1'
BF.EXISTS visited_urls 'https://example.com/page1'
Real-world example
A recommendation engine uses a Bloom filter to quickly check whether a specific product has already been recommended to a user, avoiding repetitive suggestions without needing to store an exhaustive list of every past recommendation.
Data Types;Redis Memory Optimization
Why can items not be removed from a standard Bloom filter, and what alternative structure does RedisBloom offer if you need removal support?
IntermediateA 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.
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.
Data Types;Redis Modules Overview
How does the configured false positive rate affect both the accuracy and the memory usage of a Bloom filter?
IntermediateA lower configured false positive rate makes the Bloom filter more accurate at correctly identifying items that were never actually added, but requires more memory to achieve that higher accuracy, meaning you need to balance your specific application's tolerance for occasional false positives against how much memory you are willing to allocate to the filter.
BF.RESERVE my_filter 0.001 1000000
-- 0.001 is the desired false positive rate
-- 1000000 is the expected number of items
Real-world example
A fraud detection system configures a very low false positive rate for their Bloom filter checking known fraudulent account identifiers, accepting the higher memory cost since incorrectly flagging a legitimate account as fraudulent would be costly.
Redis Memory Optimization;Data Types
How would you use a Bloom filter to prevent a cache stampede or unnecessary database lookups for items that definitely do not exist?
AdvancedYou would populate a Bloom filter with all the identifiers of items that are known to actually exist in your database, and before performing an expensive database lookup for a requested item, first check the Bloom filter, immediately returning a not found response without ever touching the database if the filter indicates the item definitely does not exist, only proceeding to the database when the filter suggests it might.
if not BF.EXISTS existing_products 'product_999':
return 'Not Found' # skip the database entirely
else:
return database.get_product('product_999')
Real-world example
An e-commerce platform prevents unnecessary database queries for clearly invalid or non existent product ids by checking a Bloom filter first, significantly reducing load on their database from bots or scanners probing for random product ids.
Caching Patterns;Redis Memory Optimization
What other probabilistic data structures does RedisBloom provide besides Bloom and Cuckoo filters, and what specific use cases do they address?
AdvancedRedisBloom also provides Count-Min Sketch for estimating the frequency of items in a large stream of data using minimal memory, and Top-K for efficiently tracking the most frequently occurring items within a data stream, both useful for analytics scenarios where you need approximate insights from very large volumes of data without the memory cost of tracking every single item exactly.
CMS.INCRBY item_frequency 'productA' 1
TOPK.ADD trending_items 'productB'
Real-world example
A trending products feature uses the Top-K structure to efficiently track which products are currently being viewed most frequently across millions of page views, without needing to maintain an exact count for every single product in their catalog.
HyperLogLog in Redis;Data Types
How do you check the current statistics and configuration of an existing Bloom filter, such as its capacity and current false positive rate?
IntermediateYou use the BF.INFO command with the filter's key name, which returns details including the filter's configured capacity, the number of items currently added, the number of internal filters used if the filter has scaled beyond its original capacity, and other useful diagnostic information about its current state.
BF.INFO my_filter
Real-world example
A team monitoring their Bloom filter's health checks BF.INFO periodically, confirming the filter has not unexpectedly grown far beyond its originally planned capacity in a way that might be affecting its accuracy or memory usage.
Redis Monitoring & Observability;Redis Memory Optimization