Maintenance and retention
Run bounded cleanup from cron, a worker, or a deployment job:
The run removes expired sessions, refresh tokens, verifications, and API keys,
plus audit logs older than the configured retention period. Every operation is
bounded by batch_size and max_batches and is safe to retry.
from datetime import timedelta
from fastauth import FastAuthOptions, MaintenanceOptions
options = FastAuthOptions(
# ...
maintenance=MaintenanceOptions(
batch_size=500,
max_batches=20,
audit_log_retention=timedelta(days=90),
continue_on_error=False,
),
)
The CLI exposes the same operation for memory, MongoDB, and Postgres: