pub struct SimpleCache<K, V> { /* private fields */ }
Implementations§
Source§impl<K, V> SimpleCache<K, V>
impl<K, V> SimpleCache<K, V>
pub fn new(max_size: usize) -> Self
pub async fn len(&self) -> Result<usize, CacheError>
pub async fn is_empty(&self) -> Result<bool, CacheError>
pub async fn insert( &self, key: K, value: V, duration: Duration, ) -> Result<(), CacheError>
pub async fn get(&self, key: &K) -> Result<V, CacheError>
pub async fn remove(&self, key: &K) -> Result<V, CacheError>
pub async fn reset_expiration( &self, key: K, duration: Duration, ) -> Result<(), CacheError>
pub async fn remove_expired( map: &Arc<RwLock<HashMap<K, (V, Instant)>>>, ) -> Result<(), CacheError>
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for SimpleCache<K, V>
impl<K, V> !RefUnwindSafe for SimpleCache<K, V>
impl<K, V> Send for SimpleCache<K, V>
impl<K, V> Sync for SimpleCache<K, V>
impl<K, V> Unpin for SimpleCache<K, V>
impl<K, V> !UnwindSafe for SimpleCache<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more