pub struct MemoryStore { /* private fields */ }Expand description
§in-memory session store
Because there is no external persistance, this session store is ephemeral and will be cleared on server restart.
§READ THIS BEFORE USING IN A PRODUCTION DEPLOYMENT
Storing sessions only in memory brings the following problems:
- All sessions must fit in available memory (important for high load services)
- Sessions stored in memory are cleared only if a client calls MemoryStore::destroy_session or MemoryStore::clear_store. If sessions are not cleaned up properly it might result in OOM
- All sessions will be lost on shutdown
- If the service is clustered particular session will be stored only on a single instance. This might be solved by using load balancers with sticky sessions. Unfortunately, this solution brings additional complexity especially if the connection is using secure transport since the load balancer has to perform SSL termination to understand where should it forward packets to
Example crates providing alternative implementations:
- async-sqlx-session postgres & sqlite
- async-redis-session
- async-mongodb-session
Implementations§
Trait Implementations§
Source§impl Clone for MemoryStore
impl Clone for MemoryStore
Source§fn clone(&self) -> MemoryStore
fn clone(&self) -> MemoryStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§fn default() -> MemoryStore
fn default() -> MemoryStore
Returns the “default value” for a type. Read more
Source§impl SessionStore for MemoryStore
impl SessionStore for MemoryStore
Source§fn load_session<'life0, 'async_trait>(
&'life0 self,
cookie_value: String,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MemoryStore: 'async_trait,
fn load_session<'life0, 'async_trait>(
&'life0 self,
cookie_value: String,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MemoryStore: 'async_trait,
Get a session from the storage backend. Read more
Source§fn store_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MemoryStore: 'async_trait,
fn store_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
MemoryStore: 'async_trait,
Store a session on the storage backend. Read more
Auto Trait Implementations§
impl Freeze for MemoryStore
impl !RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl !UnwindSafe for MemoryStore
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