Crate async_sqlx_session

Source
Expand description

§async-sqlx-session

This crate currently provides several session stores, each of which is enabled by a feature flag.

  • To use SqliteSessionStore, enable the sqlite feature on this crate.
  • To use PostgresSessionStore, enable the pg feature on this crate.
  • To use [MysqlSessionStore], enable the mysql feature on this crate.

To use the spawn_cleanup_task function for either store on async-std, enable the async_std feature. To perform session cleanup intermittently with a different runtime, use a function like:

fn clean_up_intermittently(store: &SqliteSessionStore, period: Duration) {
    let store = store.clone();
    other_runtime::spawn(async move {
        loop {
            other_runtime::sleep(period).await;
            if let Err(error) = store.cleanup().await {
                log::error!("cleanup error: {}", error);
            }
        }
    });
}

Structs§

MySqlSessionStore
sqlx mysql session store for async-sessions
PostgresSessionStore
sqlx postgres session store for async-sessions
SqliteSessionStore
sqlx sqlite session store for async-sessions