SessionStore#
- class scikitplot.cleanprompt.SessionStore(ttl_seconds=3600, max_sessions=256)[source]#
Bounded, expiring, server-side store of vaults.
- Parameters:
- ttl_secondsint, default=3600
How long a vault is retained after its last use.
- max_sessionsint, default=256
Most sessions retained. When full, the least recently used session is evicted and its vault cleared.
- Raises:
- PolicyError
If a bound is not a positive integer.
- Parameters:
Notes
Developer notes. Both bounds exist because this store holds personal data indefinitely otherwise: a long-running local app would accumulate every vault every visitor ever created. Eviction calls
clear, so an evicted vault stops referencing its secrets rather than merely becoming unreachable.A
threading.Lockguards the mapping because a Flask development server is threaded by default. The lock is held only for dictionary operations, never across a redaction.Tokens come from
secrets.token_urlsafe, so they are unguessable; a session identifier is the only thing standing between one browser tab and another’s vault.Examples
>>> store = SessionStore(ttl_seconds=60, max_sessions=4) >>> token = store.put(Vault({"[EMAIL-1]": "a@b.co"})) >>> store.get(token)["[EMAIL-1]"] 'a@b.co'
- drop(token)[source]#
Remove and clear the vault for
token, if present.- Parameters:
token (str | None)
- Return type:
None