{
  "id": "redis-set-example",
  "title": "Write to a Redis set",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/redis-set-example/",
  "summary": "",
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "f647502fc4e477a9a0a7492aaf826db9cb43133edc6905355ccb65ede8b80697",
  "sections": [
    {
      "id": "content",
      "title": "Content",
      "role": "content",
      "text": "In the example below, data is captured from the source table named `invoice` and is written to a Redis set. The `connection` is an optional parameter that refers to the corresponding connection name defined in `config.yaml`. When you specify the\n`data_type` parameter for the job, it overrides the system-wide setting `target_data_type` defined in `config.yaml`. \n\nWhen writing to a set, you must supply an extra argument, `member`, which specifies the field that will be written. In this case, the result will be a Redis set with key names based on the key expression (for example, `invoices:Germany`, `invoices:USA`) and with an expiration of 100 seconds. If 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 invoices to set by country\nsource:\n  schema: public\n  table: invoice\noutput:\n  - uses: redis.write\n    with:\n      connection: target\n      data_type: set\n      key:\n        expression: concat(['invoices:', BillingCountry])\n        language: jmespath\n      args:\n        member: InvoiceId\n      expire: 100",
      "section_id": "content"
    }
  ]
}
