Skip to main content
Version: Next

Flow Configuration Template

This document provides the configuration template for implementing the Caching Flow, enabling efficient and reliable caching of API responses based on URLs, query parameters, headers, and other request properties.

Flow Configuration

name: CachingFlow

filter:
url: api.example.com/v1/resources/* # Define the URL pattern for caching specific API endpoints.

processors:
ReadCache:
processor: ReadCache # Reads responses from the cache if available.
parameters:
- key: normalized_path_key
value: "api.example.com/v1/resources"
- key: header_key
value: "x-user-env" # Example: User environment header.
- key: path_parameter_key
value: "region" # Example: Path parameter for region.
- key: query_param_key
value: "user_id" # Example: Query parameter for user ID.
- key: body_key
value: "request_body_key" # Example: Key in the request body.

WriteCache:
processor: WriteCache # Writes responses to the cache.
parameters:
- key: ttl_seconds
value: 600 # Cache time-to-live set to 10 minutes.
- key: record_max_size_bytes
value: 8192 # Maximum size of cached responses is 8 KB.
- key: max_cache_size_megabytes
value: 200 # Cache size limited to 200 MB.
- key: normalized_path_key
value: "api.example.com/v1/resources"
- key: header_key
value: "x-user-env"
- key: path_parameter_key
value: "region"
- key: query_param_key
value: "user_id"
- key: body_key
value: "response_body_key"

flow:
request:
- from:
stream:
name: globalStream
at: start
to:
processor:
name: ReadCache

- from:
processor:
name: ReadCache
condition: cache_miss
to:
stream:
name: globalStream
at: end

response:
- from:
stream:
name: globalStream
at: start
to:
processor:
name: WriteCache

- from:
processor:
name: WriteCache
to:
stream:
name: globalStream
at: end

- from:
processor:
name: ReadCache
condition: cache_hit
to:
stream:
name: globalStream
at: end

Processor Configuration Tables

ReadCache Processor

ParameterDescriptionTypeMandatory/OptionalExample
normalized_path_keyKey used to normalize the API request path for caching.StringMandatory"api.example.com/v1/resources"
header_keyHeader used as part of the cache key.StringOptional"x-user-env"
path_parameter_keyPath parameter used to construct unique cache keys.StringOptional"region"
query_param_keyQuery parameter used to construct unique cache keys.StringOptional"user_id"
body_keyKey in the request body used for constructing cache keys.StringOptional"request_body_key"

WriteCache Processor

ParameterDescriptionTypeMandatory/OptionalExample
ttl_secondsCache time-to-live in seconds.IntegerMandatory600
record_max_size_bytesMaximum size of cached responses, in bytes.IntegerMandatory8192
max_cache_size_megabytesMaximum size of the cache, in megabytes.IntegerOptional (default: 100)200
normalized_path_keyKey used to normalize the API request path for caching.StringMandatory"api.example.com/v1/resources"
header_keyHeader used as part of the cache key.StringOptional"x-user-env"
path_parameter_keyPath parameter used to construct unique cache keys.StringOptional"region"
query_param_keyQuery parameter used to construct unique cache keys.StringOptional"user_id"
body_keyKey in the response body used for constructing cache keys.StringOptional"response_body_key"