pub struct PostBundleCache { /* private fields */ }Expand description
Intermediate-server cache for EncodedPostBundleV1 data.
Two Moka caches:
bundles: weightedCache<Id, Arc<Mutex<CachedPostBundleLocationEntry>>>with TTI. If a location_id hasn’t been queried withinCACHE_LOCATION_TTI, the entire entry is evicted. Individual bundles within an entry may also be stale (live bundles have a per-bundleexpires_at; sealed bundles are never individually stale).inflight:Cache<Id, ()>with 30-second TTL — tracks locations for which aCacheRequestTokenhas been issued but the client hasn’t uploaded yet.
Implementations§
Source§impl PostBundleCache
impl PostBundleCache
pub fn new(max_originators_per_location: usize, max_bytes: u64) -> Self
Sourcepub fn on_get(
&self,
bucket_location: &BucketLocation,
already_retrieved_peer_ids: &[Id],
peer_self: &Peer,
server_id: &ServerId,
now: TimeMillis,
) -> GetCacheResult
pub fn on_get( &self, bucket_location: &BucketLocation, already_retrieved_peer_ids: &[Id], peer_self: &Peer, server_id: &ServerId, now: TimeMillis, ) -> GetCacheResult
Called by the dispatch handler when serving a GetPostBundleV1 request.
bucket_location— used as the cache key (location_id) and included in any token issued.already_retrieved_peer_ids— originator IDs the client already has; filtered out ofcached_items.peer_self/server_id— used to sign theCacheRequestTokenif one is issued.now— current time.
Sourcepub fn on_upload(
&self,
location_id: Id,
originator_peer_id: Id,
bundle_bytes: Bytes,
server_time: TimeMillis,
is_sealed: bool,
) -> bool
pub fn on_upload( &self, location_id: Id, originator_peer_id: Id, bundle_bytes: Bytes, server_time: TimeMillis, is_sealed: bool, ) -> bool
Called by the dispatch handler when a CachePostBundleV1 upload arrives.
The token must have been verified and expiry-checked by the caller.
Returns true if accepted, false if the entry was evicted before the upload arrived.
Auto Trait Implementations§
impl Freeze for PostBundleCache
impl !RefUnwindSafe for PostBundleCache
impl Send for PostBundleCache
impl Sync for PostBundleCache
impl Unpin for PostBundleCache
impl UnsafeUnpin for PostBundleCache
impl !UnwindSafe for PostBundleCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more