pub struct SessionStore { /* private fields */ }Expand description
In-memory, lock-free session store keyed by SessionId. The
Arc<SessionState> value lets the middleware hand a cheap clone to
each request without holding a DashMap shard lock for the whole
dispatch.
Cloning a SessionStore is cheap — internally it’s an
Arc<Inner>. Pass a clone to the per-process SoloHttpState; the
background sweep task holds another clone via Arc::downgrade.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a fresh store and spawn the background sweep task on the
current tokio runtime. Panics if called outside a tokio runtime
context — callers should construct this from inside an async
context (e.g. the daemon’s startup, or
tokio::runtime::Handle::current()).
Sourcepub fn insert(&self, state: SessionState) -> SessionId
pub fn insert(&self, state: SessionState) -> SessionId
Insert a new session and return its assigned id. Each call
produces a fresh server-assigned SessionId (UUID v7).
Sourcepub fn get(&self, id: &SessionId) -> Option<Arc<SessionState>>
pub fn get(&self, id: &SessionId) -> Option<Arc<SessionState>>
Look up a session by id. Returns None if absent OR expired —
expired entries are removed lazily here so the store doesn’t
hand out stale state between sweeps. The returned
Arc<SessionState>’s last_accessed_at_ms is bumped to “now”
on a successful hit.
Sourcepub fn delete(&self, id: &SessionId) -> bool
pub fn delete(&self, id: &SessionId) -> bool
Drop a session by id. Returns true if it was present.
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Source§fn clone(&self) -> SessionStore
fn clone(&self) -> SessionStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more