content/commands/cf.addnx.md
Adds an item to a cuckoo filter if the item does not exist.
This command is similar to the combination of [CF.EXISTS]({{< relref "commands/cf.exists/" >}}) and [CF.ADD]({{< relref "commands/cf.add/" >}}). It does not add an item into the filter if its fingerprint already exists.
<note><b>Notes:</b>
CF.ADD]({{< relref "commands/cf.add/" >}}) because it first checks whether the item exists.CF.EXISTS]({{< relref "commands/cf.exists/" >}}) can result in false positive, CF.ADDNX may not add an item because it is supposedly already exist, which may be wrong.is key name for a cuckoo filter to add items to.
If key does not exist - a new cuckoo filter is created.
is an item to add.
</details>{{< highlight bash >}} redis> CF.ADDNX cf item (integer) 1 redis> CF.ADDNX cf item (integer) 0 {{< / highlight >}}
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |
{{< multitabs id="cf-addnx-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
1 for successfully adding an item to the filter or 0 if the item's fingerprint already exists in the filter.-tab-sep-
One of the following:
true for successfully adding an item to the filter or false if the item's fingerprint already exists in the filter.{{< /multitabs >}}