pub struct CachedResult {
pub fingerprint: QueryFingerprint,
pub column_names: Vec<String>,
pub rows: CompactArc<Vec<Row>>,
pub predicate: Option<Expression>,
pub cached_at: Instant,
pub last_accessed: Instant,
pub access_count: u64,
pub estimated_bytes: usize,
}Expand description
Cached query result with metadata
Fields§
§fingerprint: QueryFingerprintThe fingerprint identifying this query pattern
column_names: Vec<String>Column names in order
rows: CompactArc<Vec<Row>>Cached rows (Arc for zero-copy sharing on cache hits)
predicate: Option<Expression>The original WHERE predicate (for subsumption checking)
cached_at: InstantWhen this entry was cached
last_accessed: InstantLast access time (for LRU eviction)
access_count: u64Access count
estimated_bytes: usizeConservative estimate of memory retained by the cached rows.
Implementations§
Source§impl CachedResult
impl CachedResult
Sourcepub fn new(
fingerprint: QueryFingerprint,
column_names: Vec<String>,
rows: Vec<Row>,
predicate: Option<Expression>,
) -> Self
pub fn new( fingerprint: QueryFingerprint, column_names: Vec<String>, rows: Vec<Row>, predicate: Option<Expression>, ) -> Self
Create a new cached result
Sourcepub fn new_with_arc(
fingerprint: QueryFingerprint,
column_names: Vec<String>,
rows: CompactArc<Vec<Row>>,
predicate: Option<Expression>,
) -> Self
pub fn new_with_arc( fingerprint: QueryFingerprint, column_names: Vec<String>, rows: CompactArc<Vec<Row>>, predicate: Option<Expression>, ) -> Self
Create a new cached result with pre-wrapped Arc (avoids clone)
Use this when the caller already has a CompactArc<Vec<Row>> to avoid
an extra allocation and copy.
Sourcepub fn is_expired(&self, ttl: Duration) -> bool
pub fn is_expired(&self, ttl: Duration) -> bool
Check if this cached result has expired
Sourcepub fn is_expired_at(&self, ttl: Duration, now: Instant) -> bool
pub fn is_expired_at(&self, ttl: Duration, now: Instant) -> bool
Check if this cached result has expired, using a pre-computed now instant.
Avoids repeated Instant::now() calls (each is a syscall on macOS).
Sourcepub fn record_access(&mut self)
pub fn record_access(&mut self)
Record an access to this cached result
Trait Implementations§
Source§impl Clone for CachedResult
impl Clone for CachedResult
Source§fn clone(&self) -> CachedResult
fn clone(&self) -> CachedResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CachedResult
impl RefUnwindSafe for CachedResult
impl Send for CachedResult
impl Sync for CachedResult
impl Unpin for CachedResult
impl UnsafeUnpin for CachedResult
impl UnwindSafe for CachedResult
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