pub struct Cache { /* private fields */ }Expand description
Implementations§
Source§impl Cache
impl Cache
pub fn new(storage: Arc<dyn Storage>, clock: Arc<dyn Clock>) -> Self
Sourcepub async fn get<T: DeserializeOwned>(
&self,
key: &StorageKey,
) -> Result<Option<T>>
pub async fn get<T: DeserializeOwned>( &self, key: &StorageKey, ) -> Result<Option<T>>
Fresh value, or None when absent or expired.
Sourcepub async fn put<T: Serialize>(
&self,
key: &StorageKey,
value: &T,
ttl: Option<Duration>,
) -> Result<()>
pub async fn put<T: Serialize>( &self, key: &StorageKey, value: &T, ttl: Option<Duration>, ) -> Result<()>
Store a value. ttl of None means it stays until explicitly invalidated.
pub async fn invalidate(&self, key: &StorageKey) -> Result<()>
pub async fn invalidate_namespace(&self, namespace: &str) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Cache
impl !UnwindSafe for Cache
impl Freeze for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
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