pub struct PlanCache { /* private fields */ }Expand description
Query plan cache for repeated queries
§Task 5 Enhancement: Frequency-Gated Caching
Plans are only cached after being used 3+ times to avoid polluting the cache with one-off queries.
Implementations§
Source§impl PlanCache
impl PlanCache
Sourcepub fn with_threshold(max_entries: usize, cache_threshold: usize) -> Self
pub fn with_threshold(max_entries: usize, cache_threshold: usize) -> Self
Create with custom frequency threshold
Sourcepub fn hash_query(query: &str) -> u64
pub fn hash_query(query: &str) -> u64
Hash a query for caching
Sourcepub fn get(&mut self, query_hash: u64) -> Option<&ExecutionPlan>
pub fn get(&mut self, query_hash: u64) -> Option<&ExecutionPlan>
Get cached plan with frequency tracking
Returns cached plan if available, or None. If query is seen frequently but not cached, attempts promotion.
Sourcepub fn put(&mut self, query_hash: u64, plan: ExecutionPlan)
pub fn put(&mut self, query_hash: u64, plan: ExecutionPlan)
Register a plan for potential caching
Does not immediately cache - waits for frequency threshold.
Sourcepub fn force_put(&mut self, query_hash: u64, plan: ExecutionPlan)
pub fn force_put(&mut self, query_hash: u64, plan: ExecutionPlan)
Force-cache a plan (bypasses frequency check)
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics (legacy compatibility)
Sourcepub fn adaptive_stats(&self) -> &AdaptiveCacheStats
pub fn adaptive_stats(&self) -> &AdaptiveCacheStats
Get enhanced statistics
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 more