CF.ADD
Syntax
CF.ADD key item
- Available in:
- Redis Stack / Bloom 1.0.0
- Time complexity:
- O(k + i), where k is the number of sub-filters and i is maxIterations
Adds an item to the cuckoo filter.
Cuckoo filters can contain the same item multiple times, and consider each addition as separate.
Use CF.ADDNX
to add an item only if it does not exist.
Required arguments
key
is key name for a cuckoo filter to add the item to.
If key
does not exist - a new cuckoo filter is created.
item
is an item to add.
Return value
Returns one of these replies:
- Integer reply - where "1" means that the item has been added successfully
- [] on error (invalid arguments, wrong key type, etc.) and also when the filter is full
Complexity
O(n + i), where n is the number of sub-filters
and i is maxIterations
.
Adding items requires up to 2 memory accesses per sub-filter
.
But as the filter fills up, both locations for an item might be full.
The filter attempts to Cuckoo
swap items up to maxIterations
times.
Examples
redis> CF.ADD cf item1
(integer) 1
redis> CF.ADD cf item1
(integer) 1