pub struct Cache { /* private fields */ }Expand description
Content-addressable file cache with namespace isolation
Implementations§
Source§impl Cache
impl Cache
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 with default configuration
Sourcepub fn with_cleanup_config<P: AsRef<Path>>(
cache_dir: P,
policy: CleanupPolicy,
trigger: CleanupTrigger,
) -> Result<Self>
pub fn with_cleanup_config<P: AsRef<Path>>( cache_dir: P, policy: CleanupPolicy, trigger: CleanupTrigger, ) -> Result<Self>
Create a cache with custom cleanup configuration
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if cache is enabled
Sourcepub fn get(&self, namespace: &str, key: &str) -> Result<Option<String>>
pub fn get(&self, namespace: &str, key: &str) -> Result<Option<String>>
Get a cached value by namespace and key
Sourcepub fn set(
&self,
namespace: &str,
key: &str,
value: &str,
input_size: usize,
) -> Result<()>
pub fn set( &self, namespace: &str, key: &str, value: &str, input_size: usize, ) -> Result<()>
Set a cached value under a namespace and key
Sourcepub fn should_cleanup_periodic(&self) -> Result<bool>
pub fn should_cleanup_periodic(&self) -> Result<bool>
Check if periodic cleanup should run
Sourcepub fn should_cleanup_size(&self) -> Result<bool>
pub fn should_cleanup_size(&self) -> Result<bool>
Check if cache is over size limit
Sourcepub fn cleanup_stale(&self) -> Result<CleanupStats>
pub fn cleanup_stale(&self) -> Result<CleanupStats>
Run stale entry cleanup
Sourcepub fn cleanup_by_size(&self) -> Result<CleanupStats>
pub fn cleanup_by_size(&self) -> Result<CleanupStats>
Run size-based cleanup
Sourcepub fn stats(&self) -> Result<CacheStats>
pub fn stats(&self) -> Result<CacheStats>
Get cache statistics
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
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