3 releases (breaking)
0.3.0 | Sep 27, 2023 |
---|---|
0.2.0 | Aug 4, 2023 |
0.1.0 | Aug 4, 2023 |
#1626 in Database interfaces
10KB
120 lines
ASYNC DEADPOOL REDIS SESSION
Project status & info:
License | Crates Version | Docs |
---|---|---|
Rust library built for async session store for deadpool redis
Add as dependencies
Edit Cargo.toml file to add async_deadpool_redis_session as dependencies
[dependencies]
async_deadpool_redis_session = "0.3.0"
Usage
use async_deadpool_redis_session::{RedisSessionStore};
use async_deadpool_redis_session::async_session::{Session, SessionStore};
use async_deadpool_redis_session::deadpool_redis::{Config, Runtime};
// pool creation
let config = Config::from_url("redis://127.0.0.1:6379").unwrap();
let redis_pool = config.create_pool(Some(Runtime::Tokio1)).unwrap();
// store and session
let store = RedisSessionStore::new(redis_pool);
let mut session = Session::new();
session.insert("key", "value").unwrap();
let cookie_value = store.store_session(session).await.unwrap().unwrap();
let session = store.load_session(cookie_value).await.unwrap().unwrap();
assert_eq!(&session.get::<String>("key").unwrap(), "value");
Dependencies
~11–24MB
~362K SLoC