Skip to main content

FileStore

Struct FileStore 

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

One JSON file per session, under storage/sessions by default.

Survives a restart, needs no service to be running, and is what a single application server should use. It does not work across machines: two nodes behind a load balancer each keep their own directory, and a visitor bounced between them looks logged out on alternate requests.

Implementations§

Source§

impl FileStore

Source

pub const DEFAULT_DIRECTORY: &'static str = "storage/sessions"

Laravel’s path, relative to the application root.

Source

pub fn new(directory: impl Into<PathBuf>) -> Self

Source

pub fn with_lifetime(directory: impl Into<PathBuf>, lifetime: Duration) -> Self

Source

pub fn directory(&self) -> &Path

Trait Implementations§

Source§

impl SessionStore for FileStore

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.