pub struct ContentCache { /* private fields */ }Expand description
Thread-safe content cache with TTL-based eviction.
Uses RwLock<HashMap> — reads only acquire a read lock (no contention
between concurrent resolves). Writes acquire a write lock (infrequent:
only on cache miss or invalidation).
Data is stored behind Arc so cache hits return a cheap reference-counted
pointer instead of cloning the entire document.
Implementations§
Source§impl ContentCache
impl ContentCache
Sourcepub fn get(&self, key: &str) -> Option<Arc<Vec<u8>>>
pub fn get(&self, key: &str) -> Option<Arc<Vec<u8>>>
Get cached content if it exists and hasn’t expired.
Returns an Arc<Vec<u8>> — cheap clone (reference count bump only).
Sourcepub fn invalidate(&self, key: &str)
pub fn invalidate(&self, key: &str)
Invalidate a cache entry (call on publish/delete).
Sourcepub fn evict_expired(&self)
pub fn evict_expired(&self)
Remove all expired entries (call periodically from cleanup thread).
Auto Trait Implementations§
impl !Freeze for ContentCache
impl RefUnwindSafe for ContentCache
impl Send for ContentCache
impl Sync for ContentCache
impl Unpin for ContentCache
impl UnsafeUnpin for ContentCache
impl UnwindSafe for ContentCache
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