ReadThroughCache

Struct ReadThroughCache 

Source
pub struct ReadThroughCache<B, S, M, K, V, L>{ /* private fields */ }
Expand description

A cache wrapper that automatically loads data on miss

Implementations§

Source§

impl<B, S, M, K, V, L> ReadThroughCache<B, S, M, K, V, L>
where B: CacheBackend + DependencyBackend, S: Serializer, M: CacheMetrics, K: CacheKey + Clone + Send + Sync + 'static, V: Serialize + DeserializeOwned + Send + Sync + Clone + 'static, L: Loader<K, V>,

Source

pub fn new( manager: CacheManager<B, S, M>, loader: L, options: CacheOptions, ) -> Self

Create a new ReadThroughCache

Source

pub async fn get(&self, key: K) -> Result<Option<V>>

Get value from cache, or load it automatically if missing

Source

pub async fn refresh(&self, key: K) -> Result<()>

Force refresh a key using the loader

Auto Trait Implementations§

§

impl<B, S, M, K, V, L> Freeze for ReadThroughCache<B, S, M, K, V, L>

§

impl<B, S, M, K, V, L> !RefUnwindSafe for ReadThroughCache<B, S, M, K, V, L>

§

impl<B, S, M, K, V, L> Send for ReadThroughCache<B, S, M, K, V, L>
where L: Sync + Send, K: Send, V: Send,

§

impl<B, S, M, K, V, L> Sync for ReadThroughCache<B, S, M, K, V, L>
where L: Sync + Send, K: Sync, V: Sync,

§

impl<B, S, M, K, V, L> Unpin for ReadThroughCache<B, S, M, K, V, L>
where K: Unpin, V: Unpin,

§

impl<B, S, M, K, V, L> !UnwindSafe for ReadThroughCache<B, S, M, 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.
Source§

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

Source§

fn vzip(self) -> V