Working with Cuckoo Filters
1. Adding Elements to Filter
| Command | Returns |
|---|---|
CF.ADD key item | 1 on success |
CF.ADDNX key item | 1 if not previously present, 0 if existed |
2. Checking Element Existence
| Command | Returns |
|---|---|
CF.EXISTS key item | 1 probably present, 0 definitely absent |
CF.MEXISTS key i1 i2 ... | Per-item array |
3. Deleting Elements from Filter
| Command | Notes |
|---|---|
CF.DEL key item | Removes one occurrence; may produce false negatives if item never inserted |
CF.COUNT key item | Approximate occurrence count |
4. Adding if Not Exists
| Command | Description |
|---|---|
CF.INSERTNX key [CAPACITY c] [NOCREATE] ITEMS i ... | Add only missing items |
5. Creating Custom Cuckoo Filter
CF.RESERVE seen 1000000 BUCKETSIZE 2 MAXITERATIONS 20 EXPANSION 1
| Param | Detail |
|---|---|
| capacity | Expected items |
| BUCKETSIZE | Items per bucket (1–4) |
| MAXITERATIONS | Insertion eviction attempts |
| EXPANSION | New sub-filter growth |
6. Getting Filter Info
| Command | Returns |
|---|---|
CF.INFO key | Size, buckets, capacity, items |
7. Understanding Deletion Support
| Property | Detail |
|---|---|
| Supports DEL | Yes, unlike Bloom |
| Caveat | Deleting unknown items can cause false negatives on real items |
8. Configuring Filter Capacity
| Tradeoff | Detail |
|---|---|
| Higher capacity | More memory; better insert success rate |
| BUCKETSIZE 4 | Better load factor, slower |
9. Comparing with Bloom Filters
10. Using for Space-Efficient Sets
| Use Case | Detail |
|---|---|
| URL crawler dedup | Massive cardinality, occasional removals |
| Already-sent notifications | Bounded retention with DEL |