Working with Cuckoo Filters

1. Adding Elements to Filter

CommandReturns
CF.ADD key item1 on success
CF.ADDNX key item1 if not previously present, 0 if existed

2. Checking Element Existence

CommandReturns
CF.EXISTS key item1 probably present, 0 definitely absent
CF.MEXISTS key i1 i2 ...Per-item array

3. Deleting Elements from Filter

CommandNotes
CF.DEL key itemRemoves one occurrence; may produce false negatives if item never inserted
CF.COUNT key itemApproximate occurrence count

4. Adding if Not Exists

CommandDescription
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
ParamDetail
capacityExpected items
BUCKETSIZEItems per bucket (1–4)
MAXITERATIONSInsertion eviction attempts
EXPANSIONNew sub-filter growth

6. Getting Filter Info

CommandReturns
CF.INFO keySize, buckets, capacity, items

7. Understanding Deletion Support

PropertyDetail
Supports DELYes, unlike Bloom
CaveatDeleting unknown items can cause false negatives on real items

8. Configuring Filter Capacity

TradeoffDetail
Higher capacityMore memory; better insert success rate
BUCKETSIZE 4Better load factor, slower

9. Comparing with Bloom Filters

Cuckoo

  • Supports deletion
  • Better space at low FP
  • Insertion can fail at high load
  • Slower lookups

Bloom

  • No deletion
  • Faster inserts
  • Lower load tolerance for low FP
  • Simpler

10. Using for Space-Efficient Sets

Use CaseDetail
URL crawler dedupMassive cardinality, occasional removals
Already-sent notificationsBounded retention with DEL