iet-auth-session-cache
Authoritative session storage over the cache contract; clones share collision coordination.
iet-auth-session-cacheimplementationCache-backed session storeHow to use it
iet-auth-session-cache implements iet_auth::SessionStore over any iet_cache::Cache<Value = SessionRecord>, giving authoritative, expiring session storage. Clones share collision coordination, and scoped keys let revoke_all clear one application's sessions without touching another's. Session mechanisms such as iet-auth-session-opaque are what call into it.
// examples/htmx-starter/servers/web/tests/framework_cached_sessions.rs
use ;
use CacheSessions;
use MemoryCache;
use Principal;
use ;
let backend = new?;
let store = new?;
let other = new?;
store.insert.await?;
store.revoke_all.await?; // logout-all for "account-a" only
assert!;
assert!;
- The cache is authoritative: a miss or expiry must mean "not authenticated", never a fallback.
insertrejects collisions and already-expired records atomically within a clone group.- Distributed stores need a native atomic insert; coordination is local to clones.
How it works
CacheSessions maps the 32-byte digest to a scoped cache key and forwards each SessionStore method to the backing Cache; insert first checks for a collision and refuses already-expired records, while revoke_all clears only the namespace prefix.
flowchart LR S["CacheSessions"] --> I["insert"] S --> F["find"] S --> R["revoke"] S --> RA["revoke_all"] I --> K["scoped digest key"] I --> G["Cache get collision check"] I --> P["Cache put with ttl"] F --> Q["Cache get"] R --> V["Cache invalidate"] RA --> X["Cache invalidate_prefix"]
What it implements
- Implements
iet_auth::SessionStorefromiet-auth.
What's inside
Modules
src/lib.rs
Public API
(root)
- struct
CacheSessions pub fn new(cache: C, namespace: String) -> AppResult<Self>— Use a dedicated authoritative backend, not a second facade over shared keys. Coordination is local to clones. Distributed stores need native atomic insert.
Impl map
Clone for CacheSessions<C>SessionStore for CacheSessions<C>
Depends on
External crates: tokio
Used by
- No other framework crate depends on it directly.
In this repository
examples/htmx-starter
Source: crates/features/iet-auth-session-cache