pub struct Caches { /* private fields */ }Expand description
Multi-tier cache implementation combining an in-memory LRU cache with spill-to-disk storage. It uses a DashMap for offset-to-hash mapping and a DashSet to track cached hashes. The cache supports concurrent rebuild tasks using a thread pool.
Implementations§
Source§impl Caches
impl Caches
Sourcepub fn queued_tasks(&self) -> usize
pub fn queued_tasks(&self) -> usize
number of queued tasks in the thread pool
Sourcepub fn memory_used_index(&self) -> usize
pub fn memory_used_index(&self) -> usize
memory used by the index (exclude lru_cache which is contained in CacheObject::get_mem_size())
Sourcepub fn remove_tmp_dir(&self)
pub fn remove_tmp_dir(&self)
remove the tmp dir
Trait Implementations§
Source§impl _Cache for Caches
impl _Cache for Caches
Source§fn new(mem_size: Option<usize>, tmp_path: PathBuf, thread_num: usize) -> Selfwhere
Self: Sized,
fn new(mem_size: Option<usize>, tmp_path: PathBuf, thread_num: usize) -> Selfwhere
Self: Sized,
@param size: the size of the memory lru cache. None means no limit @param tmp_path: the path to store the cache object in the tmp file
Source§fn get_by_offset(&self, offset: usize) -> Option<Arc<CacheObject>>
fn get_by_offset(&self, offset: usize) -> Option<Arc<CacheObject>>
get object by offset, from memory or tmp file
Source§fn get_by_hash(&self, hash: ObjectHash) -> Option<Arc<CacheObject>>
fn get_by_hash(&self, hash: ObjectHash) -> Option<Arc<CacheObject>>
get object by hash, from memory or tmp file
fn get_hash(&self, offset: usize) -> Option<ObjectHash>
fn insert( &self, offset: usize, hash: ObjectHash, obj: CacheObject, ) -> Arc<CacheObject>
fn total_inserted(&self) -> usize
fn memory_used(&self) -> usize
fn clear(&self)
Auto Trait Implementations§
impl !Freeze for Caches
impl !RefUnwindSafe for Caches
impl Send for Caches
impl Sync for Caches
impl Unpin for Caches
impl UnwindSafe for Caches
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ValueSize for T
impl<T> ValueSize for T
Source§fn value_size(&self) -> usize
fn value_size(&self) -> usize
The size of this value in bytes, excluding allocated data. Read more
Source§fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usizewhere
T: 'item,
fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usizewhere
T: 'item,
The total sum of the sizes of all values in the given iterator, in
bytes. This is default-implemented by computing ValueSize::value_size
on every element and summing them. For Sized types, a more potentially
efficient implementation using Iterator::count is provided. If you are
implementing this trait manually, it is unlikely to be more efficient to
provide a manual implementation here. Read more
Source§fn value_size_sum_exact_size_iter<'item>(
iterator: impl ExactSizeIterator<Item = &'item T>,
) -> usizewhere
T: 'item,
fn value_size_sum_exact_size_iter<'item>(
iterator: impl ExactSizeIterator<Item = &'item T>,
) -> usizewhere
T: 'item,
The total sum of the sizes of all values in the given
exact-size-iterator, in bytes. This is default-implemented by using
ValueSize::value_size_sum_iter. For Sized types, a usually more
efficient implementation using ExactSizeIterator::len is provided. If
you are implementing this trait manually, it is unlikely to be more
efficient to provide a manual implementation here. Read more