pub struct TypedCache<C> { /* private fields */ }Expand description
Wraps a Cache with JSON-based typed get/set.
Implementations§
Source§impl<C: Cache> TypedCache<C>
impl<C: Cache> TypedCache<C>
Sourcepub async fn get<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>, CacheError>
pub async fn get<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, CacheError>
Fetches and deserializes a value.
Sourcepub async fn set<T: Serialize>(
&self,
key: &str,
value: &T,
ttl: Option<Duration>,
) -> Result<(), CacheError>
pub async fn set<T: Serialize>( &self, key: &str, value: &T, ttl: Option<Duration>, ) -> Result<(), CacheError>
Serializes and stores a value.
Sourcepub fn into_inner(self) -> C
pub fn into_inner(self) -> C
Returns the underlying byte cache.
Trait Implementations§
Source§impl<C: Clone> Clone for TypedCache<C>
impl<C: Clone> Clone for TypedCache<C>
Source§fn clone(&self) -> TypedCache<C>
fn clone(&self) -> TypedCache<C>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<C> Freeze for TypedCache<C>where
C: Freeze,
impl<C> RefUnwindSafe for TypedCache<C>where
C: RefUnwindSafe,
impl<C> Send for TypedCache<C>where
C: Send,
impl<C> Sync for TypedCache<C>where
C: Sync,
impl<C> Unpin for TypedCache<C>where
C: Unpin,
impl<C> UnsafeUnpin for TypedCache<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for TypedCache<C>where
C: UnwindSafe,
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