{
  "schema_version": 2,
  "id": "commands/cf.reserve",
  "title": "CF.RESERVE",
  "url": "https://redis.io/docs/latest/commands/cf.reserve/",
  "summary": "Creates a new Cuckoo Filter",
  "since": "1.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:54+01:00",
  "page_type": "content",
  "content_hash": "eb2e11d669f27947e55e6e8aa37d0c2b056d34920b7765d3eeb06ce3906f466c",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Creates an empty cuckoo filter with a single sub-filter for the initial specified capacity.\n\nAccording to the cuckoo filter behavior, the filter is likely to declare itself full before `capacity` is reached; therefore, the fill rate will likely never reach 100 percent.\nThe fill rate can be improved by using a larger `bucketsize` at the cost of a higher error rate.\nWhen the filter self-declare itself `full`, it will auto-expand by generating additional sub-filters at the cost of reduced performance and increased error rate.\nThe new sub-filter is created with size of the previous sub-filter multiplied by `expansion`.\nLike bucket size, additional sub-filters grow the error rate linearly.\n\nThe minimal false positive error rate is 2/255 ≈ 0.78% when bucket size of 1 is used.\nLarger buckets increase the error rate linearly (for example, a bucket size of 3 yields a 2.35% error rate) but improve the fill rate of the filter.\n\n`maxiterations` dictates the number of attempts to find a slot for the incoming fingerprint.\nOnce the filter gets full, high `maxIterations` value will slow down insertions.\n\nUnused capacity in prior sub-filters is automatically used when possible. \nThe filter can grow up to 32 times."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nis key name for the cuckoo filter to be created.\n</details>\n\n<details open><summary><code>capacity</code></summary>\n\nEstimated capacity for the filter.\n\nCapacity is rounded to the next `2^n` number.\n\nThe filter will likely not fill up to 100% of it's capacity. Make sure to reserve extra capacity if you want to avoid expansions.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>BUCKETSIZE bucketsize</code></summary>\n\nNumber of items in each bucket.\n\nA higher bucket size value improves the fill rate but also causes a higher error rate and slightly slower performance.\n\n`bucketsize` is an integer between 1 and 255. The default value is 2.\n</details>\n\n<details open><summary><code>MAXITERATIONS maxiterations</code></summary>\n\nNumber of attempts to swap items between buckets before declaring filter as full and creating an additional filter. \n\nA low value is better for performance and a higher number is better for filter fill rate.\n\n`maxiterations` is an integer between 1 and 65535. The default value is 20.\n</details>\n\n<details open><summary><code>EXPANSION expansion</code></summary>\n\nWhen a new filter is created, its size is the size of the current filter multiplied by `expansion`.\n\n`expansion` is an integer between 0 and 32768. The default value is 1.\n\nExpansion is rounded to the next `2^n` number. \n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> CF.RESERVE cf 1000\nOK\n\nredis> CF.RESERVE cf 1000\n(error) ERR item exists\n\nredis> CF.RESERVE cf_params 1000 BUCKETSIZE 8 MAXITERATIONS 20 EXPANSION 2\nOK"
    },
    {
      "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; Supported</span><br /> | <span title=\"Supported\">&#x2705; Flexible & Annual</span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings): `OK` if the filter was created successfully.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: invalid arguments or the key already exists.\n\n**RESP3:**\n\nOne of the following:\n* [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings): `OK` if the filter was created successfully.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: invalid arguments or the key already exists."
    }
  ],
  "examples": []
}
