Skip to main content

SharedCacheCache

Struct SharedCacheCache 

Source
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).

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§

Source§

impl SharedCacheCache

Source

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§

impl Cache for SharedCacheCache

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,

Look up the cached sv for key ("sv:{sub}"). Read more
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,

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.
Source§

impl Debug for SharedCacheCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more