Trait Cache

Source
pub trait Cache {
    type Item;

    // Required methods
    fn lookup(
        &self,
        key: &str,
    ) -> Option<impl Deref<Target = LookupStatus<Self::Item>>>;
    fn store(&self, key: &str, value: Self::Item) -> Option<Self::Item>;
    fn invalidate(&self, key: &str);
    fn clear(&self);

    // Provided methods
    fn get(&self, key: &str) -> Option<Self::Item>
       where Self::Item: Clone { ... }
    fn get_or(&self, key: &str, or: Self::Item) -> Self::Item
       where Self::Item: Clone { ... }
    fn get_or_default(&self, key: &str) -> Self::Item
       where Self::Item: Clone + Default { ... }
}

Required Associated Types§

Required Methods§

Source

fn lookup( &self, key: &str, ) -> Option<impl Deref<Target = LookupStatus<Self::Item>>>

Source

fn store(&self, key: &str, value: Self::Item) -> Option<Self::Item>

Source

fn invalidate(&self, key: &str)

Source

fn clear(&self)

Provided Methods§

Source

fn get(&self, key: &str) -> Option<Self::Item>
where Self::Item: Clone,

Source

fn get_or(&self, key: &str, or: Self::Item) -> Self::Item
where Self::Item: Clone,

Source

fn get_or_default(&self, key: &str) -> Self::Item
where Self::Item: Clone + Default,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Cache for DashmapCache<T>

Source§

type Item = T