Back to Redis

CF.COUNT

content/commands/cf.count.md

latest2.2 KB
Original Source

Returns an estimation of the number of times a given item was added to a cuckoo filter.

If you just want to check that a given item was added to a cuckoo filter, use [CF.EXISTS]({{< relref "commands/cf.exists/" >}}).

Required arguments

<details open><summary><code>key</code></summary>

is key name for a cuckoo filter.

</details> <details open><summary><code>item</code></summary>

is an item to check.

</details>

Examples

{{< highlight bash >}} redis> CF.INSERT cf ITEMS item1 item2 item2

  1. (integer) 1
  2. (integer) 1
  3. (integer) 1 redis> CF.COUNT cf item1 (integer) 1 redis> CF.COUNT cf item2 (integer) 2 {{< / highlight >}}

Redis Software and Redis Cloud compatibility

| 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> | |

Return information

{{< multitabs id="cf-count-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}), where a positive value is an estimation of the number of times item was added to the filter. An overestimation is possible, but not an underestimation. 0 means that key does not exist or that item had not been added to the filter. See the note in [CF.DEL]({{< relref "commands/cf.del/" >}}).
  • [Simple error]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments or wrong key type.

-tab-sep-

One of the following:

  • [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}), where a positive value is an estimation of the number of times item was added to the filter. An overestimation is possible, but not an underestimation. 0 means that key does not exist or that item had not been added to the filter. See the note in [CF.DEL]({{< relref "commands/cf.del/" >}}).
  • [Simple error]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: invalid arguments or wrong key type.

{{< /multitabs >}}