pub struct CacheDefinition {
pub name: String,
pub backend: String,
pub ttl: Option<String>,
pub key_params: Vec<String>,
pub default_policy: bool,
pub apply_to_effects: Vec<String>,
pub invalidate_on: Vec<String>,
pub loc: Loc,
pub leading_trivia: Vec<Trivia>,
pub trailing_trivia: Vec<Trivia>,
}Expand description
cache Name { backend:, ttl:, key:, default:, apply_to_effects:, invalidate_on: } — v2.40.0, a named, referenced result-memoization
policy resolved per tool.cache: / retrieve.cache: (mirrors
CorsDefinition’s named-and-referenced shape).
The load-bearing idea: cacheability derives from the type system’s
existing effects: pure proof — a pure tool is safe to cache by
construction. A default: true cache auto-covers every pure tool with
zero per-tool annotation; widening apply_to_effects: beyond [pure] is
allowed but the compiler names every non-pure tool it covers (W013) AND
forces a finite ttl: (T865 — you may cache a proven-deterministic result
forever, never a non-deterministic one).
Unknown fields are a hard parse error (the v2.38.0 the design decision discipline) — a cache governs correctness (serving a stale/foreign result is a real bug), so a typo’d field can never silently mean “no policy.”
Fields§
§name: String§backend: Stringredis (multi-replica, enterprise tier) or in_process (the OSS
default single-replica tier). Empty ⇒ in_process. Validated against a
closed catalog at check time.
ttl: Option<String>Time-to-live as a duration literal ("10s", "5m", "1h"), same lexer
convention as cors.max_age/tool.timeout. None ⇒ “cache forever” —
sound ONLY for a provably-pure cache; a non-pure cache with no ttl:
is axon-T865.
key_params: Vec<String>key: [param, ...] — the SUBSET of the covered tool’s parameters:
whose bound values form the cache key. Empty ⇒ ALL bound parameters
(the automatic, zero-friction default). Used when one bound arg — e.g. a
request_id — must NOT affect the key.
default_policy: booldefault: true ⇒ this cache auto-covers every eligible tool in the
module without a per-tool cache: reference. At most one per module
(axon-T863). Default false.
apply_to_effects: Vec<String>apply_to_effects: [pure, ...] — the effect classes this cache is
willing to memoise. Empty ⇒ [pure] (the only provably-safe default).
Any member beyond pure is a WIDENING (W013 names each covered tool)
and forces a finite ttl: (T865).
invalidate_on: Vec<String>invalidate_on: [Channel, ...] — an emit on any listed channel
flushes this cache’s namespace. Each must resolve to a declared
channel (axon-T864). Reuses the v1.6.0 pub/sub, not a second mechanism.
loc: Loc§leading_trivia: Vec<Trivia>v1.5.2 — leading comment trivia.
trailing_trivia: Vec<Trivia>v1.5.2 — trailing comment trivia.