3 releases

0.0.4 Sep 10, 2023
0.0.3 Sep 10, 2023
0.0.2 Sep 9, 2023
0.0.1 Sep 9, 2023

#1444 in Database interfaces

MIT license

8KB
137 lines

cryo-sessions

This crate is intended for people who want to store user sessions locally in Redis.

Example

use cryo_sessions::{Redis, Uuid, Session, SessionInfo};

let uuid = Uuid::new();
let redis = Redis::from_env(); // this method takes the redis url from the REDIS_URL environment variable
let session = Session::new();
redis.new_session(session.to_owned(), SessionInfo::new(uuid.to_owned(), "Mozilla(5.0)".into()), Duration::from_secs(2400)).await.is_ok();
redis.new_session(Session::new(), SessionInfo::new(uuid.to_owned(), "Apple Safari".into()), Duration::from_secs(3400)).await.is_ok();
let info = redis.get_information_by_session(session).await.unwrap();
println!("{:?}", info);

lib.rs:

cryo-sessions

This crate is intended for people who want to store user sessions locally in Redis.

Example

let uuid = Uuid::new();
let redis = Redis::from_env(); // this method takes the redis url from the REDIS_URL environment variable
let session = Session::new();
redis.new_session(session.to_owned(), SessionInfo::new(uuid.to_owned(), "Mozilla(5.0)".into()), Duration::from_secs(2400)).await.is_ok();
redis.new_session(session.to_owned(), SessionInfo::new(uuid.to_owned(), "Apple Safari".into()), Duration::from_secs(3400)).await.is_ok();
let info = redis.get_information_by_session(session).await.unwrap();
println!("{:?}", info);

Dependencies

~6–15MB
~194K SLoC