{
  "id": "redis-string-example",
  "title": "Write to a Redis string",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/redis-string-example/",
  "summary": "",
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "152cc2360df2eb2dbf9aa486c22098ccc8825e26b1e2855b9396d13c5fea5c79",
  "sections": [
    {
      "id": "content",
      "title": "Content",
      "role": "content",
      "text": "The string data type is useful for capturing a string representation of a single column from\na source table.\n\nIn the example job below, the `title` column is captured from the `album` table in the source.\nThe `title` is then written to the Redis target database as a string under a custom key of the\nform `AlbumTitle:42`, where the `42` is the primary key value of the table (the `albumid` column).\n\nThe `connection` is an optional parameter that refers to the corresponding connection name defined in\n[`config.yaml`](). \nWhen you specify the `data_type` parameter for the job, it overrides the system-wide setting `target_data_type` defined in `config.yaml`. Here, the `string` data type also requires an `args` subsection\nwith a `value` argument that specifies the column you want to capture from the source table.\n\nThe optional `expire` parameter sets the length of time, in seconds, that a new key will\npersist for after it is created (here, it is 86400 seconds, which equals one day).\nAfter this time, the key will be deleted automatically.\nIf you don't supply an `expire` parameter, the keys will never expire. \n\n[code example]"
    }
  ],
  "examples": [
    {
      "id": "content-ex0",
      "language": "yaml",
      "code": "name: Write album title to string\nsource:\n  table: album\n  row_format: full\noutput:\n  - uses: redis.write\n    with:\n      connection: target\n      data_type: string\n      key:\n        expression: concat(['AlbumTitle:', values(key)[0]])\n        language: jmespath\n      args:\n        value: title\n      expire: 86400",
      "section_id": "content"
    }
  ]
}
