Skip to main content
Version: 1.1.x

Read Cache Processor

Overview

The Read Cache processor provides a mechanism to store API responses, reducing redundant calls and improving performance and retrieves cached API responses if a matching cache key is found.

This processor operates on the request stream, determining whether a cached response is available for the incoming request.

ReadCache


Input and Output

  • Input Stream: Request – The processor intercepts incoming requests and checks if a valid cached response is available.

  • Output Streams: Request -

    • Cache Hit – If a cached response is found for the request, the processor returns the cached data, and the request proceeds through the response stream.

    • Cache Miss – If no cached response is found, the request is passed along for further processing, and the backend service will be called.

The ReadCache processor helps optimize performance by minimizing unnecessary backend calls and reducing latency for commonly accessed data.


Parameters

Each parameter is defined as a key-value pair inside the parameters section.

caching_key_parts

Type: list_of_strings
Required: True
List of keys to be used to generate the cache key for lookup.

Example:

- key: caching_key_parts
value:
- $.request.headers.x_api_key
- $.request.body.ID

Best Practices

  • Ensure caching_key_parts is consistent between Read Cache and Write Cache processors.

For more details on configuring Caching flows, visit the Lunar.dev Flows Documentation.


Example Usage

CacheRead:
processor: ReadCache
parameters:
- key: caching_key_parts
value:
- $.request.headers.x_api_key
- $.request.body.ID