Skip to main content

CacheSource

Trait CacheSource 

Source
pub trait CacheSource: Send + Sync {
    type Key: Eq + Hash + Clone + Send + Sync;
    type Value: Clone + Send + Sync;

    // Required method
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 Self::Key,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

The backing store an L1Cache fronts.

Abstracts “load the value for a key” so the cache is generic over any store — PolicyStore, SessionStore, CredentialStore, … — without depending on a concrete one. The associated Key and Value become the cache’s key and cached value types.

Required Associated Types§

Source

type Key: Eq + Hash + Clone + Send + Sync

The key the source is addressed by; also the cache key.

Source

type Value: Clone + Send + Sync

The value the source returns; cloned out of the cache on a hit.

Required Methods§

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 Self::Key, ) -> Pin<Box<dyn Future<Output = Result<Self::Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load the value for key from the underlying store.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<P: PolicyStore> CacheSource for P

Every PolicyStore is a CacheSource keyed by AgentId returning a PolicyDocument, so L1Cache<P> fronts any policy backend directly.