{
  "schema_version": 2,
  "id": "commands/cluster-keyslot",
  "title": "CLUSTER KEYSLOT",
  "url": "https://redis.io/docs/latest/commands/cluster-keyslot/",
  "summary": "Returns the hash slot for a key.",
  "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": "6805ebcbe91d62c86c8003b4a62bdd4d4816973cf39cce3fd6c74ac44a4af843",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Returns an integer identifying the hash slot the specified key hashes to.\nThis command is mainly useful for debugging and testing, since it exposes\nvia an API the underlying Redis implementation of the hashing algorithm.\nExample use cases for this command:\n\n1. Client libraries may use Redis in order to test their own hashing algorithm, generating random keys and hashing them with both their local implementation and using Redis `CLUSTER KEYSLOT` command, then checking if the result is the same.\n2. Humans may use this command in order to check what is the hash slot, and then the associated Redis Cluster node, responsible for a given key.\n\nThe command uses the full [Redis Cluster hashing algorithm](https://redis.io/docs/latest/operate/oss_and_stack/reference/cluster-spec#key-distribution-model), including support for hash tags. If a key contains a valid hash tag, Redis hashes only the part of the key between `{` and `}`. You can use hash tags to force multiple keys into the same hash slot so they are handled by the same node."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe key name to compute the hash slot for.\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=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | Only supported with the [OSS cluster API](https://redis.io/docs/latest/operate/rs/databases/configure/oss-cluster-api). |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): The hash slot number for the specified key\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): The hash slot number for the specified key"
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> CLUSTER KEYSLOT somekey\n(integer) 11058\n> CLUSTER KEYSLOT foo{hash_tag}\n(integer) 2515\n> CLUSTER KEYSLOT bar{hash_tag}\n(integer) 2515",
      "section_id": "examples"
    }
  ]
}
