pub struct SessionStore { /* private fields */ }Expand description
Thread-safe session store with automatic expiry cleanup.
Implementations§
Source§impl SessionStore
impl SessionStore
pub fn new(session_timeout: Duration, max_sessions: usize) -> Self
Sourcepub fn with_max_lifetime(self, lifetime: Duration) -> Self
pub fn with_max_lifetime(self, lifetime: Duration) -> Self
Set an absolute session lifetime. Sessions older than this duration
are expired regardless of activity. Returns self for chaining.
Sourcepub fn get_or_create(&self, client_session_id: Option<&str>) -> String
pub fn get_or_create(&self, client_session_id: Option<&str>) -> String
Get or create a session. Returns the session ID.
If client_session_id is provided and the session exists, it’s reused.
Otherwise a new session is created. Session IDs are always server-generated
to prevent session fixation attacks.
Sourcepub fn get(&self, session_id: &str) -> Option<Ref<'_, String, SessionState>>
pub fn get(&self, session_id: &str) -> Option<Ref<'_, String, SessionState>>
Get an immutable reference to a session.
Sourcepub fn get_mut(
&self,
session_id: &str,
) -> Option<RefMut<'_, String, SessionState>>
pub fn get_mut( &self, session_id: &str, ) -> Option<RefMut<'_, String, SessionState>>
Get a mutable reference to a session.
Sourcepub fn evict_expired(&self)
pub fn evict_expired(&self)
Remove expired sessions.
Auto Trait Implementations§
impl Freeze for SessionStore
impl !RefUnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
impl !UnwindSafe for SessionStore
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