pub struct RedisStore { /* private fields */ }Expand description
A SessionStore that keeps session contents in Redis.
Implementations§
Source§impl RedisStore
impl RedisStore
Sourcepub async fn connect(url: &str) -> Result<Self, RedisError>
pub async fn connect(url: &str) -> Result<Self, RedisError>
Connect to url (for example redis://127.0.0.1/).
The connection is established now and then multiplexed: one socket carries every session operation concurrently. If it drops, the next operation reconnects.
§Errors
If the URL does not parse or the first connection cannot be made. Connecting at startup rather than lazily is deliberate: a typo in the URL should stop the boot, not surface later as everybody being logged out.
Sourcepub fn from_client(client: Client) -> Self
pub fn from_client(client: Client) -> Self
Use an already-configured client.
Reach for this when the connection needs settings connect does not
expose. No connection is made until the first request touches a session.
Sourcepub fn ttl(self, secs: u64) -> Self
pub fn ttl(self, secs: u64) -> Self
Expire a session secs after it was last touched (default 24 hours).
§Panics
If secs is zero, which would delete every session as it was written.
Sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Prefix every Redis key (default churust:session:).
Sourcepub fn sliding(self, yes: bool) -> Self
pub fn sliding(self, yes: bool) -> Self
Whether reading a session extends its expiry (default true).
Sliding keeps an active visitor signed in without writing the session on
every request, at the cost of one EXPIRE per read. Turn it off for an
absolute lifetime, where a session ends a fixed time after it started no
matter how busy the visitor is.
Trait Implementations§
Source§impl Clone for RedisStore
impl Clone for RedisStore
Source§fn clone(&self) -> RedisStore
fn clone(&self) -> RedisStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedisStore
impl Debug for RedisStore
Source§impl SessionStore for RedisStore
impl SessionStore for RedisStore
Source§fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
raw: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<BTreeMap<String, String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
raw: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<BTreeMap<String, String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data: &'life1 BTreeMap<String, String>,
previous: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
data: &'life1 BTreeMap<String, String>,
previous: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Ok(None) to
leave the visitor’s cookie untouched. Read moreSource§fn with_session_max_age(&self, _secs: i64) -> Option<Box<dyn SessionStore>>
fn with_session_max_age(&self, _secs: i64) -> Option<Box<dyn SessionStore>>
Sessions::max_age. Read more