Skip to main content

cache

EXPERIMENTAL

This component is experimental and therefore subject to change or removal outside of major version releases.

Reads items stored within a cache resource, emitting each item as a message and shutting down once the contents of the cache have been fully consumed.

Introduced in version 1.24.0.

# Config fields, showing default values
input:
label: ""
cache:
resource: "" # No default (required)
delete_items: false
auto_replay_nacks: true

The cache must support listing its keys, which is an optional capability. Attempting to consume from any other cache will result in a connection error.

The set of keys to read is captured when the input connects, after which each item is read individually. Items deleted after the keys were captured are skipped, and items added after the keys were captured are not consumed. The order in which items are read is undefined. If the input disconnects mid-stream due to an error it will capture the set of keys again once it reconnects, in which case items may be emitted a second time.

Metadata​

This input adds the following metadata fields to each message:

  • cache_key

You can access these metadata fields using function interpolation.

Fields​

resource​

The cache resource to read from.

Type: string

delete_items​

Whether to delete items from the cache. They are deleted when they are successfully sent to the output.

Type: bool
Default: false

auto_replay_nacks​

Whether messages that are rejected (nacked) at the output level should be automatically replayed indefinitely, eventually resulting in back pressure if the cause of the rejections is persistent. If set to false these messages will instead be deleted. Disabling auto replays can greatly improve memory efficiency of high throughput streams as the original shape of the data can be discarded immediately upon consumption and mutation.

Type: bool
Default: true

Examples​

Reads all items from a file cache and writes them into a redis cache under the same keys.

input:
cache:
resource: source

output:
cache:
target: destination
key: ${! metadata("cache_key") }

cache_resources:
- label: source
file:
directory: /tmp/cache_items
- label: destination
redis:
url: tcp://localhost:6379