{
  "schema_version": 2,
  "id": "integrate/redis-data-integration/reference/data-transformation/cache",
  "title": "cache",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/cache/",
  "summary": "Cache the result of an expression or lookup",
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-09-18T16:47:14+01:00",
  "page_type": "content",
  "content_hash": "95e3732826cf7b4880c7e5829c6b42db74a5ca004305ff1ad7e8708f683fa9a1",
  "sections": [
    {
      "id": "content",
      "title": "Content",
      "role": "content",
      "text": "Cache the result of an expression or lookup. Caching avoids re-evaluating\nthe expression or re-querying Redis when the same input field values\nappear repeatedly. Cache keys are derived from the values of the input\nfields referenced by the expression, not from the full record.\n\nThe `cache:` block can be added to the following transformations and\noutput expressions:\n\n- The expression in [`add_field`](https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/add_field) (single-field and per-item form).\n- The expression in [`filter`](https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/filter).\n- The expression in [`map`](https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/map).\n- The argument expressions in [`redis.lookup`](https://redis.io/docs/latest/integrate/redis-data-integration/reference/data-transformation/lookup). The same block accepts a `lookup_cache:` variant that caches the lookup result returned by Redis.\n- The dynamic `key` and `expire` expressions of the `redis.write` output.\n\n**Flink processor only.** The classic processor silently ignores `cache:` blocks.\n\n**Properties**\n\n| Name            | Type      | Description                                                    | Required | Default |\n| --------------- | --------- | -------------------------------------------------------------- | -------- | ------- |\n| **enabled**     | `boolean` | Set to `true` to enable caching.                               | no       | `false` |\n| **max_size**    | `integer` | Maximum number of entries kept in the cache. Must be positive. | no       | `1000`  |\n| **ttl_seconds** | `integer` | Time-to-live for each entry, in seconds. Must be positive.     | no       | `60`    |\n\n**Additional Properties:** not allowed\n\n**Example**\n\n[code example]\n\nSee\n[Caching expression results](https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/caching-expression-results)\nfor additional examples."
    }
  ],
  "examples": [
    {
      "id": "content-ex0",
      "language": "yaml",
      "code": "source:\n  schema: dbo\n  table: customer\ntransform:\n  - uses: add_field\n    with:\n      field: country\n      language: sql\n      expression: country_code || ' - ' || UPPER(country_name)\n      cache:\n        enabled: true\n        max_size: 500\n        ttl_seconds: 300",
      "section_id": "content"
    }
  ]
}
