CF.ADDNX
Syntax
CF.ADDNX key item
- Available in:
- Redis Open Source / Bloom 1.0.0
- Time complexity:
- O(k + i), where k is the number of sub-filters and i is maxIterations
- ACL categories:
-
@cuckoo,@write,@slow, - Compatibility:
- Redis Enterprise and Redis Cloud compatibility
Adds an item to a cuckoo filter if the item does not exist.
This command is similar to the combination of CF.EXISTS and CF.ADD. It does not add an item into the filter if its fingerprint already exists.
- This command is slower than
CF.ADDbecause it first checks whether the item exists. - Since
CF.EXISTScan result in false positive,CF.ADDNXmay not add an item because it is supposedly already exist, which may be wrong.
Required arguments
key
is key name for a cuckoo filter to add items to.
If key does not exist - a new cuckoo filter is created.
item
is an item to add.
Examples
redis> CF.ADDNX cf item
(integer) 1
redis> CF.ADDNX cf item
(integer) 0Redis Enterprise and Redis Cloud compatibility
| Redis Enterprise |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Supported |
✅ Flexible & Annual ✅ Free & Fixed |
Return information
One of the following:
- Integer reply:
1for successfully adding an item to the filter or0if the item's fingerprint already exists in the filter. - Simple error reply in these cases: invalid arguments, wrong key type, or when the filter is full.