pub struct ByteLruCache { /* private fields */ }Expand description
Byte-budgeted LRU cache of extracted archive entry contents.
Implementations§
Source§impl ByteLruCache
impl ByteLruCache
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Build a cache sized from the MODDE_BYTE_CACHE_MIB environment variable
(defaulting to 512 MiB).
Sourcepub fn new(bytes_budget: u64) -> Self
pub fn new(bytes_budget: u64) -> Self
Build a cache holding at most bytes_budget bytes of cached entries.
Sourcepub fn get(&self, key: &ByteCacheKey) -> Option<Bytes>
pub fn get(&self, key: &ByteCacheKey) -> Option<Bytes>
Return the cached bytes for key, marking the entry most-recently-used.
Sourcepub fn insert(&self, key: ByteCacheKey, bytes: Bytes) -> Bytes
pub fn insert(&self, key: ByteCacheKey, bytes: Bytes) -> Bytes
Insert bytes under key, evicting least-recently-used entries to stay
within budget; returns the inserted bytes for chaining.
Sourcepub fn invalidate_archive(&self, archive_hash: u64)
pub fn invalidate_archive(&self, archive_hash: u64)
Drop all cached entries belonging to the given archive_hash.
Sourcepub fn bytes_used(&self) -> u64
pub fn bytes_used(&self) -> u64
Return the total number of bytes currently held in the cache.
Auto Trait Implementations§
impl !Freeze for ByteLruCache
impl !RefUnwindSafe for ByteLruCache
impl Send for ByteLruCache
impl Sync for ByteLruCache
impl Unpin for ByteLruCache
impl UnsafeUnpin for ByteLruCache
impl UnwindSafe for ByteLruCache
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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