pub trait Cache: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<i64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
sv: i64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Best-effort cache of sv:{sub} values.
Promoted to the SDK in Phase 11.Z from chat-auth’s private
SessionVersionCache trait (§3 Row 6 “replace, don’t layer”). The
shape is identical: get returns None on miss OR transient cache
error; the super::CompositeEpochRevocation composer falls
through to its super::Fetcher in either case, so Cache impls
don’t expose error variants. set is best-effort and swallows
failures internally — a failed write only means the next call will
fetch again.
key is the full sv:{sub} form (built via
super::sv_cache_key) so the SDK port matches the canonical
PAS↔consumer shared-cache contract documented in
STANDARDS_SHARED_CACHE.md §3.1.
§Implementations
super::InProcessTtlCache— opinionated per-pod TTL map; default wiring for RCW/CTW (Slice 4/5).- chat-auth-internal — KVRocks-backed reader (kept consumer-side
because it depends on
ppoppo-kvrocks, which is not in the SDK feature graph). - 11.AB+ — SDK ships a KVRocks-backed
CacheonceKVROCKS_URLACL extends to RCW/CTW.
Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Look up the cached sv for key ("sv:{sub}").
Returns None on miss OR transient cache error — the composer
treats both identically (fall through to the authoritative
fetcher), so callers don’t need separate error handling for
cache unavailability.
Sourcefn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
sv: i64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
sv: i64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Best-effort write-back after a successful fetch. Implementations
SHOULD honor the ttl (Redis SETEX, KVRocks TTL, in-process
expiration). Failures are swallowed — the next call will fetch
again.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".