pub struct QueryCache<T> { /* private fields */ }Expand description
A generic query result cache with TTL and LRU eviction.
Implementations§
Source§impl<T: Clone> QueryCache<T>
impl<T: Clone> QueryCache<T>
Sourcepub fn with_config(config: CacheConfig) -> Self
pub fn with_config(config: CacheConfig) -> Self
Create a new query cache with custom configuration.
Sourcepub fn insert_with_ttl(
&mut self,
key: CacheKey,
value: T,
ttl: Option<Duration>,
)
pub fn insert_with_ttl( &mut self, key: CacheKey, value: T, ttl: Option<Duration>, )
Insert a value with a custom TTL.
Sourcepub fn invalidate(&mut self, key: &CacheKey) -> bool
pub fn invalidate(&mut self, key: &CacheKey) -> bool
Invalidate a specific cache entry.
Sourcepub fn cleanup_expired(&mut self) -> usize
pub fn cleanup_expired(&mut self) -> usize
Remove expired entries.
Sourcepub fn stats(&self) -> &QueryCacheStats
pub fn stats(&self) -> &QueryCacheStats
Get cache statistics.
Sourcepub fn config(&self) -> &CacheConfig
pub fn config(&self) -> &CacheConfig
Get the cache configuration.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for QueryCache<T>
impl<T> RefUnwindSafe for QueryCache<T>where
T: RefUnwindSafe,
impl<T> Send for QueryCache<T>where
T: Send,
impl<T> Sync for QueryCache<T>where
T: Sync,
impl<T> Unpin for QueryCache<T>where
T: Unpin,
impl<T> UnwindSafe for QueryCache<T>where
T: UnwindSafe,
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