# memory

> 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: memory
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/caches/memory
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/caches/memory.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/caches/memory.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/caches/memory.md -->

**Type:** Cache ▼

[Cache](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/caches/memory/)[Buffer](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/buffers/memory/)

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

Stores key/value pairs in a map held in memory. This cache is therefore reset every time the service restarts. Each item in the cache has a TTL set from the moment it was last edited, after which it will be removed during the next compaction.

#### Common

```yml
caches:
  memory:
    default_ttl: 5m
    compaction_interval: 60s
    init_values: {}
```

#### Advanced

```yml
caches:
  memory:
    default_ttl: 5m
    compaction_interval: 60s
    init_values: {}
    shards: 1
```

The compaction interval determines how often the cache is cleared of expired items, and this process is only triggered on writes to the cache. Access to the cache is blocked during this process.

Item expiry can be disabled entirely by setting the `compaction_interval` to an empty string.

The field `init_values` can be used to prepopulate the memory cache with any number of key/value pairs which are exempt from TTLs:

```yaml
cache_resources:
  - label: foocache
    memory:
      default_ttl: 60s
      init_values:
        foo: bar
```

These values can be overridden during execution, at which point the configured TTL is respected as usual.

## [](#fields)Fields

### [](#compaction_interval)`compaction_interval`

The period of time to wait before each compaction, at which point expired items are removed. This field can be set to an empty string in order to disable compactions/expiry entirely.

**Type**: `string`

**Default**: `60s`

### [](#default_ttl)`default_ttl`

The default TTL of each item. After this period an item will be eligible for removal during the next compaction.

**Type**: `string`

**Default**: `5m`

### [](#init_values)`init_values`

A table of key/value pairs that should be present in the cache on initialization. This can be used to create static lookup tables.

**Type**: `string`

**Default**: `{}`

```yaml
# Examples:
init_values:
  Nickelback: "1995"
  Spice Girls: "1994"
  The Human League: "1977"
```

### [](#shards)`shards`

A number of logical shards to spread keys across, increasing the shards can have a performance benefit when processing a large number of keys.

**Type**: `int`

**Default**: `1`