pub struct AsyncCache<T> { /* private fields */ }
Implementations§
Source§impl<T> Cache<T>
impl<T> Cache<T>
pub fn new() -> Self
pub async fn fetch( &mut self, key: &str, expires_in_secs: u64, calculation: impl Fn() -> Pin<Box<dyn Future<Output = Result<T>>>> + 'static, ) -> Result<&T>
pub async fn force_fetch( &mut self, key: &str, expires_in_secs: u64, calculation: impl Fn() -> Pin<Box<dyn Future<Output = Result<T>>>> + 'static, ) -> Result<&T>
pub async fn get(&mut self, key: &str) -> Result<&T>
pub fn insert(&mut self, key: &str, value: T) -> Result<()>
pub fn expire(&mut self, key: &str) -> Result<()>
pub fn contains_key(&self, key: &str) -> bool
pub fn remove(&mut self, key: &str) -> Option<CacheItem<T>>
pub fn keys(&self) -> Vec<&String>
pub fn clear_expired(&mut self)
pub fn clear(&mut self)
Auto Trait Implementations§
impl<T> Freeze for Cache<T>
impl<T> !RefUnwindSafe for Cache<T>
impl<T> !Send for Cache<T>
impl<T> !Sync for Cache<T>
impl<T> Unpin for Cache<T>where
T: Unpin,
impl<T> !UnwindSafe for Cache<T>
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