pub struct ProfileCache { /* private fields */ }Implementations§
Source§impl ProfileCache
impl ProfileCache
pub fn new(ttl: Duration) -> Self
pub async fn get(&self, user_id: &str) -> Option<MatrixProfile>
pub async fn put(&self, profile: MatrixProfile)
Sourcepub async fn get_or_fetch<F, Fut>(
&self,
user_id: &str,
fetch: F,
) -> Option<MatrixProfile>
pub async fn get_or_fetch<F, Fut>( &self, user_id: &str, fetch: F, ) -> Option<MatrixProfile>
Returns the cached profile for the given user ID, or fetches it using the provided async callback if not cached (or expired). The fetched profile is then stored in the cache.
Trait Implementations§
Source§impl Clone for ProfileCache
impl Clone for ProfileCache
Source§fn clone(&self) -> ProfileCache
fn clone(&self) -> ProfileCache
Returns a duplicate of the value. Read more
1.0.0 · 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 Freeze for ProfileCache
impl !RefUnwindSafe for ProfileCache
impl Send for ProfileCache
impl Sync for ProfileCache
impl Unpin for ProfileCache
impl UnsafeUnpin for ProfileCache
impl !UnwindSafe for ProfileCache
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