{
  "id": "redis-hash-example",
  "title": "Write to a Redis hash",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/redis-hash-example/",
  "summary": "",
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "a4f2bc50c1597ed8e4a2abd2adb20abf2d17e1d0c65f493ee842360a63853ecd",
  "sections": [
    {
      "id": "content",
      "title": "Content",
      "role": "content",
      "text": "In the following example, the data is captured from the source table named `invoice` and is written to the Redis database as hash keys. The `connection` is an optional parameter that refers to the corresponding connection name defined in `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`. \n\nIn this case, the result will be Redis hashes with key names based on the key expression (for example, `invoice_id:1`) and with an expiration of 100 seconds.\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 invoice to hash\nsource:\n  schema: public\n  table: invoice\noutput:\n  - uses: redis.write\n    with:\n      connection: target\n      data_type: hash\n      key:\n        expression: concat(['invoice_id:', InvoiceId])\n        language: jmespath\n      expire: 100",
      "section_id": "content"
    }
  ]
}
