Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore { /* private fields */ }
Expand description

Keeps everything in memory behind one mutex. Nothing survives a restart and nothing is shared between processes, so use it for tests, development and single-instance apps only.

Implementations§

Source§

impl MemoryStore

Source

pub fn new() -> Self

An empty store.

Source

pub fn events(&self) -> Vec<SessionEvent>

Every recorded event, oldest first.

Source

pub fn session_count(&self) -> usize

Number of stored sessions, including expired ones not yet purged.

Trait Implementations§

Source§

impl Debug for MemoryStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl SessionStore for MemoryStore

Source§

fn sharded(&self) -> bool

Whether the store partitions data into buckets that must be co-located. Read more
Source§

fn insert_session( &self, session: &SessionRecord, token: &TokenHash, ) -> impl Future<Output = Result<(), StoreError>> + Send

Stores a new session with token as its current token (issued_at = created_at, unused, not superseded).
Source§

fn find_by_token( &self, token: &TokenHash, ) -> impl Future<Output = Result<Option<TokenLookup>, StoreError>> + Send

Finds the session holding token, current or superseded.
Source§

fn apply( &self, update: &SessionUpdate, ) -> impl Future<Output = Result<bool, StoreError>> + Send

Applies update atomically, in this order: Read more
Source§

fn delete_session( &self, session_id: Uuid, ) -> impl Future<Output = Result<bool, StoreError>> + Send

Deletes a session and its tokens. Returns whether it existed.
Source§

fn delete_subject_sessions( &self, subject: &str, ) -> impl Future<Output = Result<Vec<Uuid>, StoreError>> + Send

Deletes every session of subject (canonical JSON). Returns the ids it deleted.
Source§

fn list_subject_sessions( &self, subject: &str, ) -> impl Future<Output = Result<Vec<SessionRecord>, StoreError>> + Send

Every session of subject (canonical JSON), including expired ones not yet purged.
Source§

fn delete_expired( &self, now: DateTime<Utc>, idle_cutoff: DateTime<Utc>, ) -> impl Future<Output = Result<u64, StoreError>> + Send

Deletes sessions with expires_at <= now or last_seen_at <= idle_cutoff. Returns how many.
Source§

fn record_event( &self, event: &SessionEvent, ) -> impl Future<Output = Result<(), StoreError>> + Send

Appends a security event. Stores without an event log may discard it.
Source§

fn delete_events_before( &self, cutoff: DateTime<Utc>, ) -> impl Future<Output = Result<u64, StoreError>> + Send

Deletes events with at < cutoff. Returns how many. Also deletes event claims older than cutoff.
Source§

fn claim_event( &self, scope: ClaimScope<'_>, kind: EventKind, now: DateTime<Utc>, window: TimeDelta, ) -> impl Future<Output = Result<bool, StoreError>> + Send

Claims the right to report a kind event for scope, for deduplication across processes. Succeeds (true) unless a claim for the same scope and kind was made after now - window, and records now as the new claim when it does. Session and subject claims are independent. Must be atomic across processes. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoApi for T

Source§

fn into_api<A>(self) -> UseApi<T, A>
where T: Sized,

into UseApi
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more