1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Shared key/value-with-TTL store abstraction.
//!
//! Provides a single `Store<K, V>` trait so `SessionStore` (and any
//! adopter-defined kv-shaped store) can share one set of backends
//! instead of each shipping its own copy of the SQL/Valkey glue.
//! Per-backend serialization is owned by the concrete backend wrapper
//! (`SessionCodec`, `BindingsCodec`); there is no cross-backend
//! `Codec<V>` trait: the dialect-specific SQL bodies were too thin to
//! justify a `sqlx::Database` + `Codec<V>` bound surface (see
//! `session/storage/sql_helpers.rs` for the close-out rationale).
//!
//! Stores with non-kv semantics, `IdentityStore`, `FactorStore`,
//! `DeviceStore`, `SessionRegistry`, stay distinct because their
//! domain primitives (secondary indexes, set membership, pub/sub on
//! revocation) don't fit a flat key/value put.
use Future;
use Duration;
/// In-memory [`Store`] backend: `DashMap` + monotonic `Instant`
/// deadlines for TTL. Codec-free (values stored by `Clone` rather
/// than serialised) so adopters reaching for `MemoryStore` for tests
/// don't pay an encode/decode round-trip per operation. Per-store
/// wrappers like `MemoryRefreshTokenStore` are thin newtypes around
/// this backend.
///
/// Gated behind `cfg(any(test, feature = "memory"))` so production
/// builds without the `memory` feature cannot ship an in-memory store
/// by accident.
pub use MemoryStore;
/// Generic key/value-with-TTL store. Implemented by per-backend
/// wrappers (`MemoryStore`, `SqlStore`, `ValkeyStore`) so each
/// per-store newtype (e.g. `SqliteSessionStore`) reduces to a thin
/// delegating shim.
///
/// The trait carries no `cycle` / index-query primitives; those are
/// per-store specifics that live on the domain trait
/// (`SessionStore::cycle`, `RefreshTokenStore::revoke_family`, …)
/// which wraps the underlying `Store` and dispatches to backend-specific
/// helpers for the non-kv operations.
/// Generic store error. Adopters and per-backend `SqlStore` /
/// `ValkeyStore` impls use this in place of the legacy per-store
/// errors (`SqlStoreError`, `ValkeyStoreError`, …) once they have
/// been migrated.
///
/// The type parameter `B` is the backend's native error type
/// (`sqlx::Error`, `fred::error::Error`, `Infallible` for memory).