pub struct DefaultFilesMetadataCache { /* private fields */ }Expand description
Default implementation of FileMetadataCache
Collected file embedded metadata cache.
The metadata for each file is validated by comparing the cached ObjectMeta
(size and last_modified) against the current file state using cached.is_valid_for(¤t_meta).
§Internal details
The memory_limit controls the maximum size of the cache, which uses a
Least Recently Used eviction algorithm. When adding a new entry, if the total
size of the cached entries exceeds memory_limit, the least recently used entries
are evicted until the total size is lower than memory_limit.
Implementations§
Source§impl DefaultFilesMetadataCache
impl DefaultFilesMetadataCache
Sourcepub fn new(memory_limit: usize) -> Self
pub fn new(memory_limit: usize) -> Self
Create a new instance of DefaultFilesMetadataCache.
§Arguments
memory_limit: the maximum size of the cache, in bytes
Sourcepub fn memory_used(&self) -> usize
pub fn memory_used(&self) -> usize
Returns the size of the cached memory, in bytes.
Trait Implementations§
Source§impl CacheAccessor<Path, CachedFileMetadataEntry> for DefaultFilesMetadataCache
impl CacheAccessor<Path, CachedFileMetadataEntry> for DefaultFilesMetadataCache
Source§fn get(&self, key: &Path) -> Option<CachedFileMetadataEntry>
fn get(&self, key: &Path) -> Option<CachedFileMetadataEntry>
Get a cached entry if it exists. Read more
Source§fn put(
&self,
key: &Path,
value: CachedFileMetadataEntry,
) -> Option<CachedFileMetadataEntry>
fn put( &self, key: &Path, value: CachedFileMetadataEntry, ) -> Option<CachedFileMetadataEntry>
Store a value in the cache. Read more
Source§fn remove(&self, k: &Path) -> Option<CachedFileMetadataEntry>
fn remove(&self, k: &Path) -> Option<CachedFileMetadataEntry>
Remove an entry from the cache, returning the value if it existed.
Source§fn contains_key(&self, k: &Path) -> bool
fn contains_key(&self, k: &Path) -> bool
Check if the cache contains a specific key.
Source§impl FileMetadataCache for DefaultFilesMetadataCache
impl FileMetadataCache for DefaultFilesMetadataCache
Source§fn cache_limit(&self) -> usize
fn cache_limit(&self) -> usize
Returns the cache’s memory limit in bytes.
Source§fn update_cache_limit(&self, limit: usize)
fn update_cache_limit(&self, limit: usize)
Updates the cache with a new memory limit in bytes.
Source§fn list_entries(&self) -> HashMap<Path, FileMetadataCacheEntry>
fn list_entries(&self) -> HashMap<Path, FileMetadataCacheEntry>
Retrieves the information about the entries currently cached.
Auto Trait Implementations§
impl !Freeze for DefaultFilesMetadataCache
impl RefUnwindSafe for DefaultFilesMetadataCache
impl Send for DefaultFilesMetadataCache
impl Sync for DefaultFilesMetadataCache
impl Unpin for DefaultFilesMetadataCache
impl UnsafeUnpin for DefaultFilesMetadataCache
impl UnwindSafe for DefaultFilesMetadataCache
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> 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