pub struct MemoryCache { /* private fields */ }Expand description
Thread-safe memory cache with LRU eviction
Implementations§
Source§impl MemoryCache
impl MemoryCache
Sourcepub fn with_config(config: CacheConfig) -> Self
pub fn with_config(config: CacheConfig) -> Self
Create a new memory cache with custom configuration
Sourcepub fn get(&self, path: &PathBuf) -> Option<CachedFile>
pub fn get(&self, path: &PathBuf) -> Option<CachedFile>
Get a cached file by path
Sourcepub fn insert(
&self,
path: PathBuf,
content: Bytes,
mime_type: String,
etag: String,
last_modified: u64,
)
pub fn insert( &self, path: PathBuf, content: Bytes, mime_type: String, etag: String, last_modified: u64, )
Insert a file into the cache
Sourcepub fn insert_with_ttl(
&self,
path: PathBuf,
content: Bytes,
mime_type: String,
etag: String,
last_modified: u64,
ttl: Duration,
)
pub fn insert_with_ttl( &self, path: PathBuf, content: Bytes, mime_type: String, etag: String, last_modified: u64, ttl: Duration, )
Insert a file into the cache with custom TTL
Sourcepub fn stats(&self) -> Arc<CacheStats>
pub fn stats(&self) -> Arc<CacheStats>
Get cache statistics
Sourcepub fn remove_expired(&self) -> usize
pub fn remove_expired(&self) -> usize
Remove expired entries
Sourcepub fn config(&self) -> &CacheConfig
pub fn config(&self) -> &CacheConfig
Get configuration
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MemoryCache
impl RefUnwindSafe for MemoryCache
impl Send for MemoryCache
impl Sync for MemoryCache
impl Unpin for MemoryCache
impl UnsafeUnpin for MemoryCache
impl UnwindSafe for MemoryCache
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