{
  "schema_version": 2,
  "id": "commands/append",
  "title": "APPEND",
  "url": "https://redis.io/docs/latest/commands/append/",
  "summary": "Appends a string to the value of a key. Creates the key if it doesn't exist.",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T16:45:12+01:00",
  "page_type": "content",
  "content_hash": "cade5f6cbd7ab441ae1c1d8956ea6a537aab6c71c503a9a18e123f0da9571de7",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Appends a value to the string stored at `key`. If `key` does not exist, it is created with an empty string, so in that case, `APPEND` behaves like [`SET`](https://redis.io/docs/latest/commands/set)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key.\n\n</details>\n\n<details open><summary><code>value</code></summary>\n\nThe string to append to the existing value.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> EXISTS mykey\n(integer) 0\nredis> APPEND mykey \"Hello\"\n(integer) 5\nredis> APPEND mykey \" World\"\n(integer) 11\nredis> GET mykey\n\"Hello World\""
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "pattern-time-series",
      "title": "Pattern: time series",
      "role": "content",
      "text": "The `APPEND` command can be used to create a very compact representation of a\nlist of fixed-size samples, usually referred as _time series_.\nEvery time a new sample arrives we can store it using the command\n\n[code example]\n\nAccessing individual elements in the time series is not hard:\n\n* [`STRLEN`](https://redis.io/docs/latest/commands/strlen) can be used in order to obtain the number of samples.\n* [`GETRANGE`](https://redis.io/docs/latest/commands/getrange) allows for random access of elements.\n  If our time series have associated time information we can easily implement\n  a binary search to get range combining [`GETRANGE`](https://redis.io/docs/latest/commands/getrange) with the Lua scripting\n  engine available in Redis 2.6.\n* [`SETRANGE`](https://redis.io/docs/latest/commands/setrange) can be used to overwrite an existing time series.\n\nThe limitation of this pattern is that we are forced into an append-only mode\nof operation, there is no way to cut the time series to a given size easily\nbecause Redis currently lacks a command able to trim string objects.\nHowever the space efficiency of time series stored in this way is remarkable.\n\nHint: it is possible to switch to a different key based on the current Unix\ntime, in this way it is possible to have just a relatively small amount of\nsamples per key, to avoid dealing with very big keys, and to make this pattern\nmore friendly to be distributed across many Redis instances.\n\nAn example sampling the temperature of a sensor using fixed-size strings (using\na binary format is better in real implementations).\n\n\nredis> APPEND ts \"0043\"\n(integer) 4\nredis> APPEND ts \"0035\"\n(integer) 8\nredis> GETRANGE ts 0 3\n\"0043\"\nredis> GETRANGE ts 4 7\n\"0035\""
    },
    {
      "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; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the length of the string after the append operation.\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the length of the string after the append operation."
    }
  ],
  "examples": [
    {
      "id": "pattern-time-series-ex0",
      "language": "plaintext",
      "code": "APPEND timeseries \"fixed-size sample\"",
      "section_id": "pattern-time-series"
    }
  ]
}
