pub struct RemoteBlobCache { /* private fields */ }Expand description
Per-connection cache of function blobs received from a remote peer.
Content hashes make stale entries harmless (same hash = same content), so no invalidation protocol is needed. LRU eviction bounds memory usage.
Implementations§
Source§impl RemoteBlobCache
impl RemoteBlobCache
Sourcepub fn default_cache() -> Self
pub fn default_cache() -> Self
Default cache with 4096 entry capacity.
Sourcepub fn insert(&mut self, hash: FunctionHash, blob: FunctionBlob)
pub fn insert(&mut self, hash: FunctionHash, blob: FunctionBlob)
Insert a blob, evicting the least recently used entry if at capacity.
Sourcepub fn get(&mut self, hash: &FunctionHash) -> Option<&FunctionBlob>
pub fn get(&mut self, hash: &FunctionHash) -> Option<&FunctionBlob>
Look up a cached blob by hash, updating access order.
Sourcepub fn contains(&self, hash: &FunctionHash) -> bool
pub fn contains(&self, hash: &FunctionHash) -> bool
Check if a hash is cached without updating access order.
Sourcepub fn known_hashes(&self) -> Vec<FunctionHash>
pub fn known_hashes(&self) -> Vec<FunctionHash>
Return all cached hashes.
Sourcepub fn filter_known(&self, offered: &[FunctionHash]) -> Vec<FunctionHash>
pub fn filter_known(&self, offered: &[FunctionHash]) -> Vec<FunctionHash>
Return the subset of offered hashes that are in the cache.
Sourcepub fn insert_blobs(&mut self, blobs: &[(FunctionHash, FunctionBlob)])
pub fn insert_blobs(&mut self, blobs: &[(FunctionHash, FunctionBlob)])
Insert all blobs from a set, typically received from a remote call.
Auto Trait Implementations§
impl Freeze for RemoteBlobCache
impl RefUnwindSafe for RemoteBlobCache
impl Send for RemoteBlobCache
impl Sync for RemoteBlobCache
impl Unpin for RemoteBlobCache
impl UnsafeUnpin for RemoteBlobCache
impl UnwindSafe for RemoteBlobCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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