pub struct QueryCache { /* private fields */ }Expand description
Thread-safe LRU cache for query results.
Uses parking_lot::RwLock for efficient concurrent access. Read operations
(cache hits) only require a read lock; mutations (inserts, evictions,
invalidations) acquire a write lock.
Implementations§
Source§impl QueryCache
impl QueryCache
Sourcepub fn new(config: QueryCacheConfig) -> Self
pub fn new(config: QueryCacheConfig) -> Self
Create a new cache with the given configuration.
Sourcepub fn get(&self, key: &[u8]) -> Option<Vec<u8>>
pub fn get(&self, key: &[u8]) -> Option<Vec<u8>>
Look up a cached value by its raw key bytes.
Returns None if the entry does not exist or has expired.
A successful lookup increments the hit counter and moves the entry
to the most-recently-used position.
Sourcepub fn put(&self, key: &[u8], value: Vec<u8>)
pub fn put(&self, key: &[u8], value: Vec<u8>)
Insert a value into the cache.
If the value exceeds max_value_size it is silently dropped. If the
cache is at capacity, the least recently used entry is evicted first.
Sourcepub fn put_with_collection(
&self,
key: &[u8],
value: Vec<u8>,
collection: Option<&str>,
)
pub fn put_with_collection( &self, key: &[u8], value: Vec<u8>, collection: Option<&str>, )
Insert a value into the cache with an associated collection name.
The collection name is used for invalidate_collection.
Sourcepub fn invalidate(&self, key: &[u8])
pub fn invalidate(&self, key: &[u8])
Remove a specific entry from the cache.
Sourcepub fn invalidate_collection(&self, collection: &str)
pub fn invalidate_collection(&self, collection: &str)
Remove all cache entries belonging to a given collection.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Return a snapshot of the current cache statistics.
Sourcepub fn config(&self) -> &QueryCacheConfig
pub fn config(&self) -> &QueryCacheConfig
Get a reference to the cache configuration.
Sourcepub fn invalidation_policy(&self) -> InvalidationPolicy
pub fn invalidation_policy(&self) -> InvalidationPolicy
Return the invalidation policy.
Auto Trait Implementations§
impl !Freeze for QueryCache
impl !RefUnwindSafe for QueryCache
impl Send for QueryCache
impl Sync for QueryCache
impl Unpin for QueryCache
impl UnsafeUnpin for QueryCache
impl UnwindSafe for QueryCache
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.