Skip to main content

MemoryStore

Struct MemoryStore 

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

Sessions held in this process’s memory.

Everything is lost on restart and nothing is shared between processes, which makes it perfect for tests and wrong for anything running more than one worker.

Implementations§

Source§

impl MemoryStore

Source

pub fn new() -> Self

Source

pub fn with_lifetime(lifetime: Duration) -> Self

Source

pub fn len(&self) -> usize

How many sessions are held, expired ones included. For tests.

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

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 read<'a>(&'a self, id: &'a str) -> StoreFuture<'a, Option<Session>>

Load a session, or None if it is unknown or has expired.
Source§

fn write<'a>(&'a self, session: &'a Session) -> StoreFuture<'a, ()>

Persist a session under its current id.
Source§

fn destroy<'a>(&'a self, id: &'a str) -> StoreFuture<'a, ()>

Remove a session. Called on logout and after an id rotation.
Source§

fn gc(&self) -> StoreFuture<'_, usize>

Drop everything past its lifetime, returning how many were removed. Read more
Source§

fn lifetime(&self) -> Duration

How long a session may sit untouched before it is considered gone.

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, 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> 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.