{
  "schema_version": 2,
  "id": "commands/bless-set",
  "title": "BLESS SET",
  "url": "https://redis.io/docs/latest/commands/bless-set/",
  "summary": "Adds protection flags to a key against memory pressure.",
  "since": "8.12.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-23T06:19:08-08:00",
  "page_type": "content",
  "content_hash": "03356b87fcbab00f4028a48fa2a1c76eecd947c374ba40ff55efe411d594abe1",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`BLESS SET` marks a key so that Redis skips it when choosing candidates for eviction under memory pressure. The key must already exist."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key to protect. The key must already exist, or the command returns an error.\n\n</details>\n\n<details open><summary><code>NO-EVICT</code></summary>\n\nThe protection flag to add. `NO-EVICT` is currently the only supported flag.\n\n</details>"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "behavior",
      "title": "Behavior",
      "role": "content",
      "text": "- `BLESS SET` is idempotent: it returns `1` the first time the flag is added to a key, and `0` on later calls if the key already carries that flag.\n- A blessed key is skipped as an eviction candidate under every `maxmemory-policy` value. See [Protecting keys from eviction](https://redis.io/docs/latest/develop/reference/eviction#bless) for how this interacts with the `maxmemory` limit.\n- `BLESS SET` generates a `bless` [keyspace notification](https://redis.io/docs/latest/develop/pubsub/keyspace-notifications) event.\n- `BLESS SET` can itself be blocked with an out-of-memory error under the same conditions as any other write command. [`BLESS CLEAR`](https://redis.io/docs/latest/commands/bless-clear) isn't subject to this, so you can always remove protection to free up eviction candidates.\n- The flag isn't included in [`DUMP`](https://redis.io/docs/latest/commands/dump) output, and [`RESTORE`](https://redis.io/docs/latest/commands/restore) doesn't set it on the restored key. If `RESTORE` targets a key that's already blessed and uses `REPLACE`, the destination key keeps its existing protection.\n- The flag persists across restarts and replicates like any other write."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> SET session:42 \"some value\"\nOK\nredis> BLESS SET session:42 NO-EVICT\n(integer) 1\nredis> BLESS SET session:42 NO-EVICT\n(integer) 0\nredis> BLESS SET missing-key NO-EVICT\n(error) ERR no such key"
    },
    {
      "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=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `1` if the flag was added, `0` if the key already had it.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) if the key doesn't exist.\n\n**RESP3:**\n\nOne of the following:\n* [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `1` if the flag was added, `0` if the key already had it.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) if the key doesn't exist."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`BLESS CLEAR`](https://redis.io/docs/latest/commands/bless-clear) | [`BLESS GET`](https://redis.io/docs/latest/commands/bless-get) | [`BLESS SCAN`](https://redis.io/docs/latest/commands/bless-scan)"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "- [Key eviction](https://redis.io/docs/latest/develop/reference/eviction)"
    }
  ],
  "examples": []
}
