Skip to main content

CF.INSERT

Syntax​

CF.INSERT key [CAPACITY capacity] [NOCREATE] ITEMS item [item ...]

Time complexity: O(k * n), where k is the number of sub-filters and n is the number of items

ACL categories: @cuckoo_filter, @slow, @write

Adds one or more items to the Cuckoo filter at key, creating it first if it doesn't exist.

Like CF.ADD, duplicate insertions are allowed.

Parameters​

ParameterDefaultDescription
keyThe name of the filter.
CAPACITY1024Initial capacity to use if the filter is created by this command. Ignored if key already exists.
NOCREATEIf set, the filter must already exist; otherwise an error is returned instead of creating it.
ITEMSOne or more items to add. Required.

Return​

Array reply of Integer replies, one per item, in the same order as the input:

  • 1 if the item was successfully added.
  • -1 if the filter is full and the item could not be added.

Error reply: if NOCREATE is set and key does not exist, or CAPACITY is 0.

Examples​

dragonfly> CF.INSERT cf ITEMS Hello World
1) (integer) 1
2) (integer) 1

dragonfly> CF.INSERT cf CAPACITY 500 ITEMS foo
1) (integer) 1

dragonfly> CF.INSERT cf NOCREATE ITEMS bar
1) (integer) 1

dragonfly> CF.INSERT no_such_key NOCREATE ITEMS bar
(error) ERR no such key

See also​

CF.INSERTNX | CF.ADD | CF.RESERVE