pub struct CacheStorage { /* private fields */ }Expand description
Cache storage manager
Path structure: cache_dir/namespace/prefix/hash.json
Implementations§
Source§impl CacheStorage
impl CacheStorage
Sourcepub fn new<P: AsRef<Path>>(cache_dir: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(cache_dir: P) -> Result<Self>
Create a new cache storage with the given directory
Sourcepub fn get(&self, namespace: &str, key: &str) -> Result<Option<CacheEntry>>
pub fn get(&self, namespace: &str, key: &str) -> Result<Option<CacheEntry>>
Get a cache entry by namespace and key
Sourcepub fn set(&self, entry: &CacheEntry) -> Result<()>
pub fn set(&self, entry: &CacheEntry) -> Result<()>
Set a cache entry
Sourcepub fn total_size(&self) -> Result<u64>
pub fn total_size(&self) -> Result<u64>
Calculate total cache size in bytes
Sourcepub fn entry_count(&self) -> Result<usize>
pub fn entry_count(&self) -> Result<usize>
Count total cache entries
Auto Trait Implementations§
impl Freeze for CacheStorage
impl RefUnwindSafe for CacheStorage
impl Send for CacheStorage
impl Sync for CacheStorage
impl Unpin for CacheStorage
impl UnsafeUnpin for CacheStorage
impl UnwindSafe for CacheStorage
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