pub struct PlanCache { /* private fields */ }Expand description
LRU cache for query plans
Implementations§
Source§impl PlanCache
impl PlanCache
Sourcepub fn peek(&self, key: &str) -> Option<&CachedPlan>
pub fn peek(&self, key: &str) -> Option<&CachedPlan>
Read-only cache probe — no LRU promotion, no mutation.
Use this with a read() lock in the hot query path so concurrent
readers don’t serialize on a write lock. Falls back to None when
the entry is expired or has a pending replan; the caller must then
re-acquire a write() lock and call get() to handle eviction and
miss insertion.
Sourcepub fn get(&mut self, key: &str) -> Option<&CachedPlan>
pub fn get(&mut self, key: &str) -> Option<&CachedPlan>
Get a cached plan by key
Sourcepub fn insert(&mut self, key: String, plan: CachedPlan)
pub fn insert(&mut self, key: String, plan: CachedPlan)
Insert a plan into the cache
Sourcepub fn remove(&mut self, key: &str) -> Option<CachedPlan>
pub fn remove(&mut self, key: &str) -> Option<CachedPlan>
Remove an entry from the cache
Sourcepub fn invalidate<F>(&mut self, predicate: F)
pub fn invalidate<F>(&mut self, predicate: F)
Invalidate entries matching a predicate
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn prune_expired(&mut self)
pub fn prune_expired(&mut self)
Prune expired entries
pub fn record_observation(&mut self, key: &str, rows_scanned: u64)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PlanCache
impl RefUnwindSafe for PlanCache
impl Send for PlanCache
impl Sync for PlanCache
impl Unpin for PlanCache
impl UnsafeUnpin for PlanCache
impl UnwindSafe for PlanCache
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
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>
Converts
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>
Converts
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>
Wrap the input message
T in a tonic::Request