pub struct DefaultFilesMetadataCache { /* private fields */ }Expand description
Default implementation of FileMetadataCache
Collected file embedded metadata cache.
The metadata for each file is invalidated when the file size or last modification time have been changed.
§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.
§Extra Handling
Users should use the Self::get and Self::put methods. The
Self::get_with_extra and Self::put_with_extra methods simply call
get and put, respectively.
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<ObjectMeta, Arc<dyn FileMetadata>> for DefaultFilesMetadataCache
impl CacheAccessor<ObjectMeta, Arc<dyn FileMetadata>> for DefaultFilesMetadataCache
type Extra = ObjectMeta
Source§fn get(&self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
fn get(&self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
Source§fn get_with_extra(
&self,
k: &ObjectMeta,
_e: &Self::Extra,
) -> Option<Arc<dyn FileMetadata>>
fn get_with_extra( &self, k: &ObjectMeta, _e: &Self::Extra, ) -> Option<Arc<dyn FileMetadata>>
Source§fn put(
&self,
key: &ObjectMeta,
value: Arc<dyn FileMetadata>,
) -> Option<Arc<dyn FileMetadata>>
fn put( &self, key: &ObjectMeta, value: Arc<dyn FileMetadata>, ) -> Option<Arc<dyn FileMetadata>>
Source§fn put_with_extra(
&self,
key: &ObjectMeta,
value: Arc<dyn FileMetadata>,
_e: &Self::Extra,
) -> Option<Arc<dyn FileMetadata>>
fn put_with_extra( &self, key: &ObjectMeta, value: Arc<dyn FileMetadata>, _e: &Self::Extra, ) -> Option<Arc<dyn FileMetadata>>
Source§fn remove(&mut self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
fn remove(&mut self, k: &ObjectMeta) -> Option<Arc<dyn FileMetadata>>
Source§fn contains_key(&self, k: &ObjectMeta) -> bool
fn contains_key(&self, k: &ObjectMeta) -> bool
Source§impl FileMetadataCache for DefaultFilesMetadataCache
impl FileMetadataCache for DefaultFilesMetadataCache
Source§fn cache_limit(&self) -> usize
fn cache_limit(&self) -> usize
Source§fn update_cache_limit(&self, limit: usize)
fn update_cache_limit(&self, limit: usize)
Source§fn list_entries(&self) -> HashMap<Path, FileMetadataCacheEntry>
fn list_entries(&self) -> HashMap<Path, FileMetadataCacheEntry>
Auto Trait Implementations§
impl !Freeze for DefaultFilesMetadataCache
impl RefUnwindSafe for DefaultFilesMetadataCache
impl Send for DefaultFilesMetadataCache
impl Sync for DefaultFilesMetadataCache
impl Unpin 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
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