SyncCache

Struct SyncCache 

Source
pub struct SyncCache<K, V> { /* private fields */ }

Implementations§

Source§

impl<K, V> SyncCache<K, V>
where K: Hash + Eq + Clone + Send + 'static, V: Clone + ValueSize + Send + 'static,

Source

pub fn new() -> Arc<SyncCache<K, V>>

Source

pub fn with_name(name: Option<String>) -> Arc<SyncCache<K, V>>

Source

pub fn get(&self, key: K, compute: impl FnOnce() -> V) -> V

Source

pub fn entries(arc: Arc<SyncCache<K, V>>) -> impl Iterator<Item = (K, V)>

Source

pub fn remove(&self, key: &K)

Source

pub fn clear(&self)

Trait Implementations§

Source§

impl<K, V> CacheControl for SyncCache<K, V>
where K: Eq + Hash + Send + 'static, V: Clone + ValueSize + Send + 'static,

Source§

fn name(&self) -> Option<&str>

Source§

fn clean<'life0, 'async_trait>( &'life0 self, threshold: f64, time_scale: f64, ) -> Pin<Box<dyn Future<Output = (usize, f64)> + Send + 'async_trait>>
where 'life0: 'async_trait, SyncCache<K, V>: 'async_trait,

Source§

impl<K, V> Default for SyncCache<K, V>
where K: Default, V: Default,

Source§

fn default() -> SyncCache<K, V>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K, V> !Freeze for SyncCache<K, V>

§

impl<K, V> RefUnwindSafe for SyncCache<K, V>

§

impl<K, V> Send for SyncCache<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for SyncCache<K, V>
where K: Send, V: Send,

§

impl<K, V> Unpin for SyncCache<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for SyncCache<K, V>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.