Cache configuration for in-memory data caching and performance optimization
caches
The caches clause defines one or more named in‑memory caches. Caches allow
pipelines (actions, backends, scripts, etc.) to store and reuse values for a
limited time, reducing repeated backend lookups and improving overall
performance.
Each cache sub-block declares a logical key space where keys map to a
collection (vector) of values. Entries can optionally expire automatically if a
timeout is configured, or per insertion when values are written.
Only the metadata (cache names and timeouts) is configured here. The actual insertion, lookup, and invalidation operations occur at runtime via pipeline actions (e.g. actions that add or read cached values inside AAA processing), Lua scripts, or management APIs.
Syntax
caches {
cache "NAME" {
# Optional default expiration
timeout 60s;
}
cache "SESSIONS" {
timeout 30m; # 30 minutes
}
}
Cache block
A cache block supports:
| Statement | Type | Required | Description |
|---|---|---|---|
timeout | duration | No | Default TTL applied to inserted keys if the insertion call does not override it. See Duration Units. |
If timeout is omitted, keys inserted without an explicit timeout will
persist until explicitly removed or the process restarts.
See these cache usage examples:
- Lua cache API documentation - Lua cache API usage, including rate limiting.
@initpipeline - Use thecacheaction to pre-populate cache entries when configuration loads or reloads.cacheaction - Store values in a configured cache.totpaction - Read values from cache and update cache entries for TOTP replay protection.
Example
caches {
cache "USER_ATTRIBUTES" {
timeout 5m; # 5 minutes
}
cache "SESSION_DATA" {
timeout 30m; # 30 minutes
}
cache "RATE_LIMIT" {
timeout 1h; # 1 hour
}
}