Skip to main content

CacheDefinition

Struct CacheDefinition 

Source
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: String

redis (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: bool

default: 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.

Trait Implementations§

Source§

impl Debug for CacheDefinition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CacheDefinition

Source§

fn default() -> CacheDefinition

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more