{
  "schema_version": 2,
  "id": "commands/cluster-countkeysinslot",
  "title": "CLUSTER COUNTKEYSINSLOT",
  "url": "https://redis.io/docs/latest/commands/cluster-countkeysinslot/",
  "summary": "Returns the number of keys in a hash slot.",
  "since": "3.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:21+01:00",
  "page_type": "content",
  "content_hash": "e2c4e658fb64fff2bc7b0fd3b6e5f5bfb374910cce5b6c14a6dd52265cebd7e9",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Returns the number of keys in the specified Redis Cluster hash slot. The\ncommand only queries the local data set, so contacting a node\nthat is not serving the specified hash slot will always result in a count of\nzero being returned.\n\n> [!NOTE]\n> During atomic slot migration operations (available since Redis 8.4.0), keys being imported or trimmed will be filtered out from the results."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>slot</code></summary>\n\nThe hash slot to count the keys in.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): The number of keys in the specified hash slot, or an error if the hash slot is invalid.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): The number of keys in the specified hash slot, or an error if the hash slot is invalid."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> CLUSTER COUNTKEYSINSLOT 7000\n(integer) 50341",
      "section_id": "examples"
    }
  ]
}
