pub struct Sessions { /* private fields */ }Implementations§
Source§impl Sessions
impl Sessions
Sourcepub fn new(ttl: Duration, capacity: usize) -> Self
pub fn new(ttl: Duration, capacity: usize) -> Self
Create a new session store with the given parameters
Sourcepub async fn new_session(
&self,
payload: Bytes,
content_type: Mime,
) -> (Ulid, RwLockReadGuard<'_, Session>)
pub async fn new_session( &self, payload: Bytes, content_type: Mime, ) -> (Ulid, RwLockReadGuard<'_, Session>)
Create and insert a new session in the store
Sourcepub async fn get_session(
&self,
id: Ulid,
) -> Option<RwLockReadGuard<'_, Session>>
pub async fn get_session( &self, id: Ulid, ) -> Option<RwLockReadGuard<'_, Session>>
Find a session in the store
Sourcepub async fn get_session_mut(
&self,
id: Ulid,
) -> Option<RwLockMappedWriteGuard<'_, Session>>
pub async fn get_session_mut( &self, id: Ulid, ) -> Option<RwLockMappedWriteGuard<'_, Session>>
Get a mutable reference to a session from the store
Sourcepub async fn delete_session(&self, id: Ulid) -> bool
pub async fn delete_session(&self, id: Ulid) -> bool
Delete a session from the store
Sourcepub fn eviction_task(
&self,
interval: Duration,
) -> impl Future<Output = ()> + Send + Sync + 'static
pub fn eviction_task( &self, interval: Duration, ) -> impl Future<Output = ()> + Send + Sync + 'static
A loop which evicts keys if the capacity is reached
Sourcepub async fn fill_for_mem_check(&self, entry_size: usize)
pub async fn fill_for_mem_check(&self, entry_size: usize)
Fill the sessions storage to check how much memory it might use on max capacity
§Panics
It panics if the session storage is not empty
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sessions
impl !RefUnwindSafe for Sessions
impl Send for Sessions
impl Sync for Sessions
impl Unpin for Sessions
impl !UnwindSafe for Sessions
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