async_deadpool_redis_session

Crates.ioasync_deadpool_redis_session
lib.rsasync_deadpool_redis_session
version0.3.0
sourcesrc
created_at2023-08-04 10:43:36.298878
updated_at2023-09-27 01:23:49.331793
descriptiondeadpool redis async session
homepagehttps://github.com/iamsauravsharma/async_deadpool_redis_session
repositoryhttps://github.com/iamsauravsharma/async_deadpool_redis_session
max_upload_size
id934959
size17,102
Saurav Sharma (iamsauravsharma)

documentation

README

ASYNC DEADPOOL REDIS SESSION

Project status & info:

License Crates Version Docs
License: MIT Crate 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");
Commit count: 14

cargo fmt