Struct ExtensionCacheStore
pub struct ExtensionCacheStore { /* private fields */ }Expand description
Bounded type-erased cache storage owned by an extension executor.
Implementations§
§impl ExtensionCacheStore
impl ExtensionCacheStore
pub fn new() -> ExtensionCacheStore
pub fn new() -> ExtensionCacheStore
Create an empty cache store with default limits.
§Examples
use tenferro_runtime::ExtensionCacheStore;
let store = ExtensionCacheStore::new();
assert_eq!(store.len(), 0);pub fn with_limits(limits: ExtensionCacheLimits) -> ExtensionCacheStore
pub fn with_limits(limits: ExtensionCacheLimits) -> ExtensionCacheStore
Create an empty cache store with explicit limits.
pub const fn limits(&self) -> ExtensionCacheLimits
pub const fn limits(&self) -> ExtensionCacheLimits
Return the active cache limits.
pub fn set_limits(&mut self, limits: ExtensionCacheLimits)
pub fn set_limits(&mut self, limits: ExtensionCacheLimits)
Resize the store and evict least-recently-used entries if needed.
pub fn put<T>(
&mut self,
key: ExtensionCacheKey,
value: T,
retained_bytes: usize,
)
pub fn put<T>( &mut self, key: ExtensionCacheKey, value: T, retained_bytes: usize, )
Insert or replace a typed cache entry.
pub fn put_with_retained_bytes<T, F>(
&mut self,
key: ExtensionCacheKey,
value: T,
retained_bytes: F,
)
pub fn put_with_retained_bytes<T, F>( &mut self, key: ExtensionCacheKey, value: T, retained_bytes: F, )
Insert or replace a typed cache entry whose retained bytes are computed from the current value whenever stats are requested.
Use this for entries that mutate after insertion, such as compiled execution plans with backend-owned nested caches.
§Examples
use tenferro_runtime::{ExtensionCacheKey, ExtensionCacheStore, ExtensionCacheSelector};
let mut store = ExtensionCacheStore::new();
let key = ExtensionCacheKey::new("example.cache.v1", "plans", 0);
store.put_with_retained_bytes(key, Vec::<usize>::with_capacity(2), |values| {
values.capacity().saturating_mul(std::mem::size_of::<usize>())
});
let values = store.get_mut::<Vec<usize>>(&key).unwrap();
values.reserve_exact(4);
let retained_capacity = values.capacity();
assert_eq!(
store.stats(ExtensionCacheSelector::All).retained_bytes,
retained_capacity * std::mem::size_of::<usize>()
);pub fn get<T>(&mut self, key: &ExtensionCacheKey) -> Option<&T>
pub fn get<T>(&mut self, key: &ExtensionCacheKey) -> Option<&T>
Get a typed cache entry, updating its LRU position.
pub fn get_mut<T>(&mut self, key: &ExtensionCacheKey) -> Option<&mut T>
pub fn get_mut<T>(&mut self, key: &ExtensionCacheKey) -> Option<&mut T>
Get a mutable typed cache entry, updating its LRU position.
pub fn clear_selected(&mut self, selector: ExtensionCacheSelector)
pub fn clear_selected(&mut self, selector: ExtensionCacheSelector)
Clear entries selected by selector.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clear every extension cache entry.
pub fn stats(&self, selector: ExtensionCacheSelector) -> CacheStats
pub fn stats(&self, selector: ExtensionCacheSelector) -> CacheStats
Return cache-style stats for entries selected by selector.
Trait Implementations§
§impl Debug for ExtensionCacheStore
impl Debug for ExtensionCacheStore
§impl Default for ExtensionCacheStore
impl Default for ExtensionCacheStore
§fn default() -> ExtensionCacheStore
fn default() -> ExtensionCacheStore
Auto Trait Implementations§
impl Freeze for ExtensionCacheStore
impl !RefUnwindSafe for ExtensionCacheStore
impl Send for ExtensionCacheStore
impl Sync for ExtensionCacheStore
impl Unpin for ExtensionCacheStore
impl UnsafeUnpin for ExtensionCacheStore
impl !UnwindSafe for ExtensionCacheStore
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
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 more