{
  "schema_version": 2,
  "id": "commands/cf.insert",
  "title": "CF.INSERT",
  "url": "https://redis.io/docs/latest/commands/cf.insert/",
  "summary": "Adds one or more items to a Cuckoo Filter. A filter will be created if it does not exist",
  "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": "00f953d17e1e38830fe15eb7d69e48afad1a75385685727e2390993b524c8226",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Adds one or more items to a cuckoo filter, allowing the filter to be created with a custom capacity if it does not exist yet.\n\nThis command is similar to [`CF.ADD`](https://redis.io/docs/latest/commands/cf.add), except that more than one item can be added and capacity can be specified."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nis key name for a cuckoo filter to add items to.\n\nIf `key` does not exist - a new cuckoo filter is created.\n</details>\n\n<details open><summary><code>ITEMS item...</code></summary>\n\nOne or more items to add.\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>CAPACITY capacity</code></summary>\n    \nSpecifies the desired capacity of the new filter, if this filter does not exist yet.\n    \nIf the filter already exists, then this parameter is ignored.\n    \nIf the filter does not exist yet and this parameter is *not* specified, then the filter is created with the module-level default capacity which is 1024.\n\nSee [`CF.RESERVE`](https://redis.io/docs/latest/commands/cf.reserve) for more information on cuckoo filter capacities.\n</details>\n    \n<details open><summary><code>NOCREATE</code></summary>\n  \nIf specified, prevents automatic filter creation if the filter does not exist (Instead, an error is returned).\n    \nThis option is mutually exclusive with `CAPACITY`.\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> CF.INSERT cf CAPACITY 1000 ITEMS item1 item2 \n1) (integer) 1\n2) (integer) 1\n\n\n\nredis> CF.INSERT cf1 CAPACITY 1000 NOCREATE ITEMS item1 item2 \n(error) ERR not found\n\n\n\nredis> CF.RESERVE cf2 2 BUCKETSIZE 1 EXPANSION 0\nOK\nredis> CF.INSERT cf2 ITEMS 1 1 1 1\n1) (integer) 1\n2) (integer) 1\n3) (integer) -1\n4) (integer) -1"
    },
    {
      "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\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays), where each element is an [integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `1` when the item is added successfully, or `-1` when the item cannot be added because the filter is full.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) when the number of arguments or key type is incorrect, and also when `NOCREATE` is specified and `key` does not exist.\n\n**RESP3:**\n\n* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays), where each element is either a [boolean reply](https://redis.io/docs/latest/develop/reference/protocol-spec#booleans) of `true` for successfully adding an item, or an [integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers) of `-1` when the item cannot be added because the filter is full.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) when the number of arguments or key type is incorrect, and also when `NOCREATE` is specified and `key` does not exist."
    }
  ],
  "examples": []
}
