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
Parameter | Description | Type | Mandatory/Optional | Example |
---|---|---|---|---|
normalized_path_key | Key used to normalize the API request path for caching. | String | Mandatory | "api.example.com/v1/resources" |
header_key | Header used as part of the cache key. | String | Optional | "x-user-env" |
path_parameter_key | Path parameter used to construct unique cache keys. | String | Optional | "region" |
query_param_key | Query parameter used to construct unique cache keys. | String | Optional | "user_id" |
body_key | Key in the request body used for constructing cache keys. | String | Optional | "request_body_key" |
WriteCache Processor
Parameter | Description | Type | Mandatory/Optional | Example |
---|---|---|---|---|
ttl_seconds | Cache time-to-live in seconds. | Integer | Mandatory | 600 |
record_max_size_bytes | Maximum size of cached responses, in bytes. | Integer | Mandatory | 8192 |
max_cache_size_megabytes | Maximum size of the cache, in megabytes. | Integer | Optional (default: 100) | 200 |
normalized_path_key | Key used to normalize the API request path for caching. | String | Mandatory | "api.example.com/v1/resources" |
header_key | Header used as part of the cache key. | String | Optional | "x-user-env" |
path_parameter_key | Path parameter used to construct unique cache keys. | String | Optional | "region" |
query_param_key | Query parameter used to construct unique cache keys. | String | Optional | "user_id" |
body_key | Key in the response body used for constructing cache keys. | String | Optional | "response_body_key" |