Crate tower_sessions_file_store

Source
Expand description

§Overview

A session storage that stores each session in a seperate file in a special folder (default “.sessions”)

Useful when you want something more persistant than a in memory store but don’t want to setup an entire database, especially during local development. Should work fine in production environments though.

§Expiry

You can enable automatically deleting expired sessions like this:

let deletion_task = tokio::task::spawn(
    session_store
    .clone()
    .continuously_delete_expired(tokio::time::Duration::from_secs(60)),
);

By default, it will only load sessions to check their expirty if the last modified date of the file is at least 60 seconds. You can adjust this with set_minimum_expiry_date. Ideally the expiry date would be the same as the duration of your sessions.

Structs§

FileSessionStorage
A Session storage that stores each session, JSON encoded, on the local disk.