Skip to main content

CacheStore

Trait CacheStore 

Source
pub trait CacheStore:
    Send
    + Sync
    + Debug {
    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        now: Instant,
    ) -> Pin<Box<dyn Future<Output = Option<Entry>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        source: Uuid,
        entry: Entry,
        now: Instant,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn retract<'life0, 'async_trait>(
        &'life0 self,
        source: Uuid,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn entry_count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Where verified entries live.

Exists so the in-process store stays exactly what it was — the version four review rounds hardened — while a shared L2 can sit behind it. A single-instance deployment keeps byte-identical behaviour and no Redis dependency; a multi-replica one gets entries and, critically, retractions that cross process boundaries.

Async because an L2 is a network hop. Blocking one inside an async proxy would stall the runtime on a cache lookup, which is precisely the wrong place to lose latency.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, now: Instant, ) -> Pin<Box<dyn Future<Output = Option<Entry>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch a live entry, if one exists.

Source

fn put<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, source: Uuid, entry: Entry, now: Instant, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store an entry under key, proven by source.

source is passed separately because a backend has to index by it: retraction arrives naming a decision, not a key, and one decision can back several keys once the same prompt is seen under more than one ladder.

Source

fn retract<'life0, 'async_trait>( &'life0 self, source: Uuid, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Drop every entry proven by source. Returns how many went.

Source

fn entry_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Entries currently held, for tests and /metrics.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§