pub enum SessionDriver {
Memory,
Database,
Cache,
Cookie,
}Expand description
Which SessionStore to build.
use rainier_session::SessionDriver;
use rainier_support::Setting;
assert_eq!(SessionDriver::parse("cookie").unwrap(), SessionDriver::Cookie);
assert!(SessionDriver::parse("redis").is_err(), "sessions go in the cache, not a driver of their own");Note what is not here: redis. Sessions in Redis are the cache
driver pointed at Redis, which is one store to configure rather than
two, and one connection pool rather than two.
Variants§
Memory
This process only. Sessions vanish on restart and are not shared between instances, so a second instance logs everyone out.
The default because it needs nothing, and wrong for anything with more than one process.
Database
A table in the application’s own database.
Shared, durable, and revocable. Needs the migration —
DatabaseSessionStore::migrations() — and something to call
prune() periodically.
Cache
Whatever the cache is pointed at: Redis, a Redis Cluster, or Memcached, all behind one port.
The cache expires them itself, so nothing has to sweep.
Cookie
The whole session, encrypted, in the cookie.
No server state at all — and therefore no way to revoke a session short of rotating the key, and a hard size limit. Read the docs before choosing it.
Implementations§
Source§impl SessionDriver
impl SessionDriver
Source§impl SessionDriver
impl SessionDriver
Sourcepub fn is_durable(&self) -> bool
pub fn is_durable(&self) -> bool
Whether sessions survive a restart of the process that made them.
Sourcepub fn is_revocable(&self) -> bool
pub fn is_revocable(&self) -> bool
Whether the server can end a session it has already issued.
false for Cookie, and that is the property that
decides whether it is usable: a logout, a password change and a stolen
cookie all need this.
Whether every instance of the application sees the same sessions.