= cache
:type: output
:status: stable
:categories: ["Services"]



////
     THIS FILE IS AUTOGENERATED!

     To make changes, edit the corresponding source file under:

     https://github.com/redpanda-data/connect/tree/main/internal/impl/<provider>.

     And:

     https://github.com/redpanda-data/connect/tree/main/cmd/tools/docs_gen/templates/plugin.adoc.tmpl
////

// © 2024 Redpanda Data Inc.


component_type_dropdown::[]


Stores each message in a xref:components:caches/about.adoc[cache].


[tabs]
======
Common::
+
--

```yml
# Common config fields, showing default values
output:
  label: ""
  cache:
    target: "" # No default (required)
    key: ${!count("items")}-${!timestamp_unix_nano()}
    max_in_flight: 64
```

--
Advanced::
+
--

```yml
# All config fields, showing default values
output:
  label: ""
  cache:
    target: "" # No default (required)
    key: ${!count("items")}-${!timestamp_unix_nano()}
    ttl: 60s # No default (optional)
    max_in_flight: 64
```

--
======

Caches are configured as xref:components:caches/about.adoc[resources], where there's a wide variety to choose from.

:cache-support: aws_dynamodb=certified, aws_s3=certified, file=certified, memcached=certified, memory=certified, nats_kv=certified, redis=certified, ristretto=certified, couchbase=community, mongodb=community, sql=community, multilevel=community, ttlru=community, gcp_cloud_storage=community, lru=community, noop=community

The `target` field must reference a configured cache resource label like follows:

```yaml
output:
  cache:
    target: foo
    key: ${!json("document.id")}

cache_resources:
  - label: foo
    memcached:
      addresses:
        - localhost:11211
      default_ttl: 60s
```

In order to create a unique `key` value per item you should use function interpolations described in xref:configuration:interpolation.adoc#bloblang-queries[Bloblang queries].

== Performance

This output benefits from sending multiple messages in flight in parallel for improved performance. You can tune the max number of in flight messages (or message batches) with the field `max_in_flight`.

== Fields

=== `target`

The target cache to store messages in.


*Type*: `string`


=== `key`

The key to store messages by, function interpolation should be used in order to derive a unique key for each message.
This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].


*Type*: `string`

*Default*: `"${!count(\"items\")}-${!timestamp_unix_nano()}"`

```yml
# Examples

key: ${!count("items")}-${!timestamp_unix_nano()}

key: ${!json("doc.id")}

key: ${!meta("kafka_key")}
```

=== `ttl`

The 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, and those that do not will fall back to their generally configured TTL setting.
This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].


*Type*: `string`

Requires version 3.33.0 or newer

```yml
# Examples

ttl: 60s

ttl: 5m

ttl: 36h
```

=== `max_in_flight`

The maximum number of messages to have in flight at a given time. Increase this to improve throughput.


*Type*: `int`

*Default*: `64`


