Command builders for Redis Cuckoo filter (CF.*) operations.
A Cuckoo filter is a probabilistic data structure similar to a Bloom filter but with two key advantages: it supports deletion of previously added items, and it can report approximate item counts. Like Bloom filters, Cuckoo filters may return false positives but never false negatives. The trade-off is slightly higher memory usage per element compared to Bloom filters.
All functions in this module are pure and return a command list (a list of
strings) suitable for passing to Redis.command/2 or Redis.pipeline/2.
Examples
# Reserve a Cuckoo filter for up to 10_000 items
Redis.command(conn, Cuckoo.reserve("users", 10_000))
# Add, check, and delete an item
Redis.pipeline(conn, [
Cuckoo.add("users", "alice"),
Cuckoo.exists("users", "alice"),
Cuckoo.del("users", "alice")
])
Summary
Functions
Adds an item to a Cuckoo filter, creating the filter if it does not exist.
Deletes an item from a Cuckoo filter.
Checks whether an item may exist in a Cuckoo filter.
Functions
Adds an item to a Cuckoo filter, creating the filter if it does not exist.
Deletes an item from a Cuckoo filter.
This is the main advantage over Bloom filters. Returns 1 if the item was found and deleted, 0 otherwise. Deleting an item that was not added may cause false negatives for other items.
Checks whether an item may exist in a Cuckoo filter.
Returns 1 if the item may exist (possible false positive), 0 if the item definitely does not exist.
@spec reserve(String.t(), non_neg_integer(), keyword()) :: [String.t()]