pub struct QueryCache { /* private fields */ }Expand description
Thread-safe two-tier query cache.
Implementations§
Source§impl QueryCache
impl QueryCache
Sourcepub fn new(tier1_capacity: usize, tier2_capacity: usize, ttl_secs: u64) -> Self
pub fn new(tier1_capacity: usize, tier2_capacity: usize, ttl_secs: u64) -> Self
Create a new cache with given capacities and TTL in seconds.
Sourcepub fn get_query(&self, key: &str) -> Option<String>
pub fn get_query(&self, key: &str) -> Option<String>
Look up a cached query response. Key format: “endpoint:query:k”
Sourcepub fn insert_query(&self, key: String, json_response: String)
pub fn insert_query(&self, key: String, json_response: String)
Cache a query response.
Sourcepub fn get_block_text(&self, block_idx: usize) -> Option<String>
pub fn get_block_text(&self, block_idx: usize) -> Option<String>
Look up cached block text by index.
Sourcepub fn insert_block_text(&self, block_idx: usize, text: String)
pub fn insert_block_text(&self, block_idx: usize, text: String)
Cache block text by index.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Invalidate all cached entries (called on store/rebuild).
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics.
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> 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> 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