{
  "id": "keysonlyreader",
  "title": "KeysOnlyReader",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/readers/keysonlyreader/",
  "summary": "Gets key names from a database.",
  "tags": [
    "docs",
    "operate",
    "stack"
  ],
  "last_updated": "2026-04-22T11:55:45+02:00",
  "page_type": "content",
  "content_hash": "aa58d456c02174f4b321155cfda255368abedd23716e277b47d9f770c2c2104e",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "The `KeysOnlyReader` only extracts the key names from a database."
    },
    {
      "id": "constructors",
      "title": "Constructors",
      "role": "content",
      "text": "You can use one of these constructors to create a new `KeysOnlyReader` object:\n\n[code example]"
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "| Name | Type | Default value | Description |\n|------|------|---------------|-------------|\n| pattern | string | \"\\*\" (match all keys) | Get all keys that match this pattern |\n| scanSize | integer | 10000 | The scan command's size limit |"
    },
    {
      "id": "output-records",
      "title": "Output records",
      "role": "returns",
      "text": "Each output record is a string that represents the key's name."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Get all keys in the database:\n\n[code example]\n\nOnly get keys that start with \"user:\":\n\n[code example]"
    }
  ],
  "examples": [
    {
      "id": "constructors-ex0",
      "language": "java",
      "code": "public KeysOnlyReader()\n\npublic KeysOnlyReader(int scanSize, String pattern)",
      "section_id": "constructors"
    },
    {
      "id": "examples-ex0",
      "language": "java",
      "code": "KeysOnlyReader reader = new KeysOnlyReader();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "java",
      "code": "KeysOnlyReader reader = new KeysOnlyReader(1000, \"user:*\");",
      "section_id": "examples"
    }
  ]
}
