CF.ADDNX 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 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.ADD because it first checks whether the item exists.
  • Since CF.EXISTS can result in false positive, CF.ADDNX may not add an item because it is supposedly already exist, which may be wrong.

Required arguments


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.

Return value

Returns one of these replies:

  • Integer reply, where 0 means that the item's fingerprint already exist in the filter, and 1 means that the item has been successfully added to the filter.
  • [] on error (invalid arguments, wrong key type, etc.) and also when the filter is full.


redis> CF.ADDNX cf item
(integer) 1
redis> CF.ADDNX cf item
(integer) 0

Back to top ↑