pub trait _Cache {
// Required methods
fn new(
mem_size: Option<usize>,
tmp_path: PathBuf,
thread_num: usize,
) -> Self
where Self: Sized;
fn get_hash(&self, offset: usize) -> Option<ObjectHash>;
fn insert(
&self,
offset: usize,
hash: ObjectHash,
obj: CacheObject,
) -> Arc<CacheObject> ⓘ;
fn get_by_offset(&self, offset: usize) -> Option<Arc<CacheObject>>;
fn get_by_hash(&self, h: ObjectHash) -> Option<Arc<CacheObject>>;
fn total_inserted(&self) -> usize;
fn memory_used(&self) -> usize;
fn clear(&self);
}Expand description
Trait defining the interface for a multi-tier cache system. This cache supports insertion and retrieval of objects by both offset and hash, as well as memory usage tracking and clearing functionality.
Required Methods§
fn new(mem_size: Option<usize>, tmp_path: PathBuf, thread_num: usize) -> Selfwhere
Self: Sized,
fn get_hash(&self, offset: usize) -> Option<ObjectHash>
fn insert( &self, offset: usize, hash: ObjectHash, obj: CacheObject, ) -> Arc<CacheObject> ⓘ
fn get_by_offset(&self, offset: usize) -> Option<Arc<CacheObject>>
fn get_by_hash(&self, h: ObjectHash) -> Option<Arc<CacheObject>>
fn total_inserted(&self) -> usize
fn memory_used(&self) -> usize
fn clear(&self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".