{
  "schema_version": 2,
  "id": "commands/bf.reserve",
  "title": "BF.RESERVE",
  "url": "https://redis.io/docs/latest/commands/bf.reserve/",
  "summary": "Creates a new Bloom 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": "d0a88bc6594d1eeae135ebd293857156d0ca45e6b20f9a04eb606990ea2993e4",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound `error_rate`.\n\nBy default, the filter auto-scales by creating additional sub-filters when `capacity` is reached.\nThe new sub-filter is created with size of the previous sub-filter multiplied by `expansion`.\n\nThough the filter can scale up by creating sub-filters, it is recommended to reserve the estimated required `capacity` since maintaining and querying\nsub-filters requires additional memory (each sub-filter uses an extra bits and hash function) and consume  further CPU time than an equivalent filter that had\nthe right capacity at creation time.\n\nThe optimal number of hash functions is `ceil(-ln(error_rate) / ln(2))`.\n\nThe required number of bits per item, given the desired `error_rate` and the optimal number of hash functions, is `-ln(error_rate) / ln(2)^2`. Hence, the required number of bits in the filter is `capacity * -ln(error_rate) / ln(2)^2`.\n\n* **1%**    error rate requires  7 hash functions and  9.585 bits per item.\n* **0.1%**  error rate requires 10 hash functions and 14.378 bits per item.\n* **0.01%** error rate requires 14 hash functions and 19.170 bits per item."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nis key name for the Bloom filter to be created.\n</details>\n\n<details open><summary><code>error_rate</code></summary>\n\nThe desired probability for false positives. The rate is a decimal value between 0 and 1.\nFor example, for a desired false positive rate of 0.1% (1 in 1000), error_rate should be set to 0.001.\n</details>\n\n<details open><summary><code>capacity</code></summary>\n\nThe number of entries intended to be added to the filter.\nIf your filter allows scaling, performance will begin to degrade after adding more items than this number.\nThe actual degradation depends on how far the limit has been exceeded. Performance degrades linearly with the number of `sub-filters`.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>NONSCALING</code></summary>\n\nPrevents the filter from creating additional sub-filters if initial capacity is reached.\nNon-scaling filters requires slightly less memory than their scaling counterparts. The filter returns an error when `capacity` is reached.\n</details>\n\n<details open><summary><code>EXPANSION expansion</code></summary>\n\nWhen `capacity` is reached, an additional sub-filter is created.\nThe size of the new sub-filter is the size of the last sub-filter multiplied by `expansion`, specified as a positive integer.\n\nIf the number of items to be stored in the filter is unknown, you use an `expansion` of `2` or more to reduce the number of sub-filters.\nOtherwise, you use an `expansion` of `1` to reduce memory consumption. The default value is `2`.\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> BF.RESERVE bf 0.01 1000\nOK\n\n\n\nredis> BF.RESERVE bf 0.01 1000\n(error) ERR item exists\n\n\n\nredis> BF.RESERVE bf_exp 0.01 1000 EXPANSION 2\nOK\n\n\n\nredis> BF.RESERVE bf_non 0.01 1000 NONSCALING\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": []
}
