Crates.io | async_deadpool_redis_session |
lib.rs | async_deadpool_redis_session |
version | 0.3.0 |
source | src |
created_at | 2023-08-04 10:43:36.298878 |
updated_at | 2023-09-27 01:23:49.331793 |
description | deadpool redis async session |
homepage | https://github.com/iamsauravsharma/async_deadpool_redis_session |
repository | https://github.com/iamsauravsharma/async_deadpool_redis_session |
max_upload_size | |
id | 934959 |
size | 17,102 |
Project status & info:
License | Crates Version | Docs |
---|---|---|
Rust library built for async session store for deadpool redis
Edit Cargo.toml file to add async_deadpool_redis_session as dependencies
[dependencies]
async_deadpool_redis_session = "0.3.0"
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");