pub struct SharedCacheCache { /* private fields */ }Expand description
Adapter implementing the SDK’s super::Cache (sv-specific shape,
Option<i64>) over any substrate that implements
ppoppo_infra::Cache (the workspace cache trait used by
ppoppo-kvrocks in production and any in-memory impl in tests).
§Promoted from chat-api in 0.10.0
chat-api shipped this exact bridge as
chat_api::session_version::KvCache since Phase 11.Z Slice 3
(71af9f45). Promoting to the SDK in 0.10.0 closes the duplication:
every consumer reading the canonical STANDARDS_SHARED_CACHE.md §3.1
sv:{sub} namespace uses one shared adapter against any
ppoppo_infra::Cache impl. Replaces, doesn’t layer (see
RFC_2026-05-08 §4.1 lock).
§Substrate-agnostic by construction
The SDK depends on the ppoppo-infra trait crate (small, Redis-free)
and never on the substrate crate (ppoppo-kvrocks pulls Redis client
deps). Consumers wire whatever cache they want — Arc<KvCache> cast
to Arc<dyn ppoppo_infra::Cache> for production, in-memory mocks
for tests. Hexagonal Category 3 (Remote-but-owned).
§Best-effort contract preserved
super::Cache::get returns None on miss OR transient cache
error; super::Cache::set is fire-and-forget. Errors from the
underlying ppoppo_infra::Cache are swallowed per the
super::CompositeEpochRevocation documented fall-through-to-fetcher
policy.
§TTL clamping
ppoppo_infra::Cache::set accepts Option<i32> seconds. Sub-second
Duration values would round to 0 and trigger immediate-delete on
KVRocks (EXPIRE 0 semantics) — clamped to 1s minimum so the
entry is at least visible to the very next request. Upper-bound
clamps to i32::MAX guard against a future SV_CACHE_TTL > 68 years
silently truncating.
Implementations§
Sourcepub fn new(inner: Arc<dyn InfraCache>) -> Self
pub fn new(inner: Arc<dyn InfraCache>) -> Self
Build from any Arc<dyn ppoppo_infra::Cache>. Production
consumers wire an Arc<KvCache> cast at the call site:
use std::sync::Arc;
use pas_external::epoch::SharedCacheCache;
use ppoppo_infra::Cache as InfraCache;
use ppoppo_kvrocks::KvCache;
let kv: Arc<dyn InfraCache> = Arc::new(KvCache::new(client));
Arc::new(SharedCacheCache::new(kv))Trait Implementations§
Source§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 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,
Source§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,
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,
ttl (Redis SETEX, KVRocks TTL, in-process
expiration). Failures are swallowed — the next call will fetch
again.