Skip to main content

CF.RESERVE

Syntax

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

Time complexity: O(1)

ACL categories: @cuckoo_filter, @fast, @write

Creates a new Cuckoo filter at key using capacity as the initial sizing estimate. 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.
capacityInitial sizing estimate. Dragonfly divides it by BUCKETSIZE and rounds the resulting base bucket count up to the next power of two, so the effective slot capacity can differ from this value.
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.
EXPANSION1Growth factor for new sub-filters. 0 disables expansion; a nonzero value is rounded up to the next power of two.

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) ERR item exists

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

See also

CF.ADD | CF.ADDNX | CF.INSERT | CF.INFO