CacheDriver

Struct CacheDriver 

Source
pub struct CacheDriver<K, V, L>
where K: Clone + Eq + Hash + Ord + Debug + Send + 'static, V: Clone + Debug + Send + 'static, L: CacheLoader<K = K, V = V>,
{ /* private fields */ }
Expand description

Combine a CacheBackend and a [Loader] into a single [Cache]

Implementations§

Source§

impl<K, V, L> CacheDriver<K, V, L>
where K: Clone + Eq + Hash + Ord + Debug + Send + 'static, V: Clone + Debug + Send + 'static, L: CacheLoader<K = K, V = V>,

Source

pub fn new(backend: CacheBackend<K, V>, loader: Arc<L>) -> Self

Create new, empty cache with given loader function.

Trait Implementations§

Source§

impl<K, V, L> Debug for CacheDriver<K, V, L>
where K: Clone + Eq + Hash + Ord + Debug + Send + 'static + Debug, V: Clone + Debug + Send + 'static + Debug, L: CacheLoader<K = K, V = V> + Debug,

Source§

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

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

impl<K, V, L> Drop for CacheDriver<K, V, L>
where K: Clone + Eq + Hash + Ord + Debug + Send + 'static, V: Clone + Debug + Send + 'static, L: CacheLoader<K = K, V = V>,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<K, V, L> LoadingCache for CacheDriver<K, V, L>
where K: Clone + Eq + Hash + Ord + Debug + Send + 'static, V: Clone + Debug + Send + 'static, L: CacheLoader<K = K, V = V>,

Source§

type K = K

Cache key.
Source§

type V = V

Cache value.
Source§

type GetExtra = <L as CacheLoader>::Extra

Extra data that is provided during GET but that is NOT part of the cache key.
Source§

fn get_if_present(&self, k: Self::K) -> Option<Self::V>

Get value from cache. Read more
Source§

fn get_with_status<'life0, 'async_trait>( &'life0 self, k: Self::K, extra: Self::GetExtra, ) -> Pin<Box<dyn Future<Output = (Self::V, CacheGetStatus)> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get value from cache and the status. Read more
Source§

fn put<'life0, 'async_trait>( &'life0 self, k: Self::K, v: Self::V, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Side-load an entry into the cache. If the cache previously contained a value associated with key, the old value is replaced by value. Read more
Source§

fn invalidate(&self, k: Self::K)

Discard any cached value for the key. Read more
Source§

fn get<'life0, 'async_trait>( &'life0 self, k: Self::K, extra: Self::GetExtra, ) -> Pin<Box<dyn Future<Output = Self::V> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get value from cache. Read more

Auto Trait Implementations§

§

impl<K, V, L> Freeze for CacheDriver<K, V, L>

§

impl<K, V, L> !RefUnwindSafe for CacheDriver<K, V, L>

§

impl<K, V, L> Send for CacheDriver<K, V, L>

§

impl<K, V, L> Sync for CacheDriver<K, V, L>

§

impl<K, V, L> Unpin for CacheDriver<K, V, L>

§

impl<K, V, L> !UnwindSafe for CacheDriver<K, V, L>

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, 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, 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.