# cache

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: cache
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: connect/components/processors/cache
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/processors/cache.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/processors/cache.adoc
page-git-created-date: "2024-09-09"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/cache.md -->

**Type:** Processor ▼

[Processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/cache/)[Output](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/outputs/cache/)

**Available in:** Cloud, [Self-Managed](https://docs.redpanda.com/connect/components/processors/cache/%20%22View%20the%20Self-Managed%20version%20of%20this%20component%22)

Performs operations against a [cache resource](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/caches/about/) for each message, allowing you to store or retrieve data within message payloads.

#### Common

```yml
processors:
  label: ""
  cache:
    resource: "" # No default (required)
    operator: "" # No default (required)
    key: "" # No default (required)
    value: "" # No default (optional)
```

#### Advanced

```yml
processors:
  label: ""
  cache:
    resource: "" # No default (required)
    operator: "" # No default (required)
    key: "" # No default (required)
    value: "" # No default (optional)
    ttl: "" # No default (optional)
```

For use cases where you wish to cache the result of processors, consider using the [`cached` processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/cached/) instead.

This processor will interpolate functions within the `key` and `value` fields individually for each message. This allows you to specify dynamic keys and values based on the contents of the message payloads and metadata. You can find a list of functions in [Bloblang queries](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

## [](#examples)Examples

### [](#deduplication)Deduplication

Deduplication can be done using the add operator with a key extracted from the message payload, since it fails when a key already exists we can remove the duplicates using a [`mapping` processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/mapping/):

```yaml
pipeline:
  processors:
    - cache:
        resource: foocache
        operator: add
        key: '${! json("message.id") }'
        value: "storeme"
    - mapping: root = if errored() { deleted() }

cache_resources:
  - label: foocache
    redis:
      url: tcp://TODO:6379
```

### [](#deduplication-batch-wide)Deduplication Batch-Wide

Sometimes it’s necessary to deduplicate a batch of messages (also known as a window) by a single identifying value. This can be done by introducing a [`branch` processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/branch/), which executes the cache only once on behalf of the batch, in this case with a value make from a field extracted from the first and last messages of the batch:

```yaml
pipeline:
  processors:
    # Try and add one message to a cache that identifies the whole batch
    - branch:
        request_map: |
          root = if batch_index() == 0 {
            json("id").from(0) + json("meta.tail_id").from(-1)
          } else { deleted() }
        processors:
          - cache:
              resource: foocache
              operator: add
              key: ${! content() }
              value: t
    # Delete all messages if we failed
    - mapping: |
        root = if errored().from(0) {
          deleted()
        }
```

### [](#hydration)Hydration

It’s possible to enrich payloads with content previously stored in a cache by using the [`branch`](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/branch/) processor:

```yaml
pipeline:
  processors:
    - branch:
        processors:
          - cache:
              resource: foocache
              operator: get
              key: '${! json("message.document_id") }'
        result_map: 'root.message.document = this'

        # NOTE: If the data stored in the cache is not valid JSON then use
        # something like this instead:
        # result_map: 'root.message.document = content().string()'

cache_resources:
  - label: foocache
    memcached:
      addresses: [ "TODO:11211" ]
```

## [](#fields)Fields

### [](#key)`key`

A key to use with the cache. This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

### [](#operator)`operator`

The [operation](#operators) to perform with the cache.

**Type**: `string`

**Options**: `set`, `add`, `get`, `delete`, `exists`

### [](#resource)`resource`

The [`cache` resource](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/caches/about/) to target with this processor.

**Type**: `string`

### [](#ttl)`ttl`

The time to live (TTL) of each individual item as a duration string. After this period an item will be eligible for removal during the next compaction. Not all caches support per-key TTLs, those that do will have a configuration field `default_ttl`, and those that do not will fall back to their generally configured TTL setting. This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

```yaml
# Examples:
ttl: 60s

# ---

ttl: 5m

# ---

ttl: 36h
```

### [](#value)`value`

A value to use with the cache (when applicable). This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

## [](#operators)Operators

### [](#set)`set`

Set a key in the cache to a value. If the key already exists the contents are overridden.

### [](#add)`add`

Set a key in the cache to a value. If the key already exists the action fails with a 'key already exists' error, which can be detected with [processor error handling](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/error_handling/).

### [](#get)`get`

Retrieve the contents of a cached key and replace the original message payload with the result. If the key does not exist the action fails with an error, which can be detected with [processor error handling](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/error_handling/).

### [](#exists)`exists`

Check whether a specific key is in the cache and replace the original message payload with `true` if the key exists, or `false` if it doesn’t.

### [](#delete)`delete`

Delete a key and its contents from the cache. If the key does not exist the action is a no-op and will not fail with an error.