Skip to main content

CF.RESERVE

Syntax

CF.RESERVE key capacity [BUCKETSIZE bucketsize] [MAXITERATIONS maxiterations] [EXPANSION expansion]

Time complexity: O(1)

ACL categories: @cuckoo

Creates a new Cuckoo filter at key with an initial capacity of at least capacity items. If key already exists, an error is returned.

Unlike Bloom filters, Cuckoo filters support deletion of individual items.

Parameters

ParameterDefaultDescription
keyThe name of the filter.
capacityEstimated number of items the filter should hold. Actual capacity is rounded up to the next power of two.
BUCKETSIZE2Number of fingerprint slots per bucket. Higher values improve fill rate but increase false positive probability.
MAXITERATIONS20Maximum number of cuckoo-displacement attempts before declaring the filter full. Must be between 1 and 65535.
EXPANSION1When the filter is full, a new sub-filter of size capacity * expansion is created. 0 disables expansion.

Return

Simple string reply: OK if the filter was created successfully.

Error reply: if key already exists, or a parameter is out of range.

Examples

dragonfly> CF.RESERVE cf 1000
OK

dragonfly> CF.RESERVE cf 1000
(error) item exists

dragonfly> CF.RESERVE cf_custom 10000 BUCKETSIZE 4 MAXITERATIONS 50 EXPANSION 2
OK