struct DefaultFilesMetadataCacheState {
lru_queue: LruQueue<Path, (ObjectMeta, Arc<dyn FileMetadata>)>,
memory_limit: usize,
memory_used: usize,
cache_hits: HashMap<Path, usize>,
}Expand description
Handles the inner state of the DefaultFilesMetadataCache struct.
Fields§
§lru_queue: LruQueue<Path, (ObjectMeta, Arc<dyn FileMetadata>)>§memory_limit: usize§memory_used: usize§cache_hits: HashMap<Path, usize>Implementations§
Source§impl DefaultFilesMetadataCacheState
impl DefaultFilesMetadataCacheState
fn new(memory_limit: usize) -> Self
Sourcefn get(&mut self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
fn get(&mut self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
Returns the respective entry from the cache, if it exists and the size and last_modified
properties from [ObjectMeta] match.
If the entry exists, it becomes the most recently used.
Sourcefn contains_key(&self, k: &ObjectMeta) -> bool
fn contains_key(&self, k: &ObjectMeta) -> bool
Checks if the metadata is currently cached (entry exists and the size and last_modified
properties of [ObjectMeta] match).
The LRU queue is not updated.
Sourcefn put(
&mut self,
key: ObjectMeta,
value: Arc<dyn FileMetadata>,
) -> Option<Arc<dyn FileMetadata>>
fn put( &mut self, key: ObjectMeta, value: Arc<dyn FileMetadata>, ) -> Option<Arc<dyn FileMetadata>>
Adds a new key-value pair to cache, meaning LRU entries might be evicted if required.
If the key is already in the cache, the previous metadata is returned.
If the size of the metadata is greater than the memory_limit, the value is not inserted.
Sourcefn evict_entries(&mut self)
fn evict_entries(&mut self)
Evicts entries from the LRU cache until memory_used is lower than memory_limit.
Sourcefn remove(&mut self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
fn remove(&mut self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
Removes an entry from the cache and returns it, if it exists.
Auto Trait Implementations§
impl Freeze for DefaultFilesMetadataCacheState
impl !RefUnwindSafe for DefaultFilesMetadataCacheState
impl Send for DefaultFilesMetadataCacheState
impl Sync for DefaultFilesMetadataCacheState
impl Unpin for DefaultFilesMetadataCacheState
impl !UnwindSafe for DefaultFilesMetadataCacheState
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
§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>
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>
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