Back to Redis

CLUSTER COUNTKEYSINSLOT

content/commands/cluster-countkeysinslot.md

latest1.4 KB
Original Source

Returns the number of keys in the specified Redis Cluster hash slot. The command only queries the local data set, so contacting a node that is not serving the specified hash slot will always result in a count of zero being returned.

{{< note>}}During atomic slot migration operations (available since Redis 8.4.0), keys being imported or trimmed will be filtered out from the results. {{< /note >}}

> CLUSTER COUNTKEYSINSLOT 7000
(integer) 50341

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | |

Return information

{{< multitabs id="cluster-countkeysinslot-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: The number of keys in the specified hash slot, or an error if the hash slot is invalid.

-tab-sep-

Integer reply: The number of keys in the specified hash slot, or an error if the hash slot is invalid.

{{< /multitabs >}}