pub struct StatementCache<S> { /* private fields */ }Expand description
Generic statement cache that works with any statement type.
Implementations§
Source§impl<S: Clone> StatementCache<S>
impl<S: Clone> StatementCache<S>
Sourcepub fn per_tenant(max_tenants: usize, statements_per_tenant: usize) -> Self
pub fn per_tenant(max_tenants: usize, statements_per_tenant: usize) -> Self
Create a per-tenant cache.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics.
Sourcepub fn get(&self, key: &StatementKey) -> Option<S>
pub fn get(&self, key: &StatementKey) -> Option<S>
Get a cached statement (global mode).
Sourcepub fn get_for_tenant(
&self,
tenant_id: &TenantId,
key: &StatementKey,
) -> Option<S>
pub fn get_for_tenant( &self, tenant_id: &TenantId, key: &StatementKey, ) -> Option<S>
Get a cached statement for a tenant.
Sourcepub fn insert(&self, key: StatementKey, statement: S)
pub fn insert(&self, key: StatementKey, statement: S)
Insert a statement into the global cache.
Sourcepub fn insert_for_tenant(
&self,
tenant_id: &TenantId,
key: StatementKey,
statement: S,
)
pub fn insert_for_tenant( &self, tenant_id: &TenantId, key: StatementKey, statement: S, )
Insert a statement for a specific tenant.
Sourcepub fn record_execution(&self, key: &StatementKey, duration_us: f64)
pub fn record_execution(&self, key: &StatementKey, duration_us: f64)
Record an execution for statistics.
Sourcepub fn record_tenant_execution(
&self,
tenant_id: &TenantId,
key: &StatementKey,
duration_us: f64,
)
pub fn record_tenant_execution( &self, tenant_id: &TenantId, key: &StatementKey, duration_us: f64, )
Record an execution for a tenant.
Sourcepub fn invalidate_tenant(&self, tenant_id: &TenantId)
pub fn invalidate_tenant(&self, tenant_id: &TenantId)
Invalidate all statements for a tenant.
Sourcepub fn invalidate(&self, key: &StatementKey)
pub fn invalidate(&self, key: &StatementKey)
Invalidate a specific statement globally.
Auto Trait Implementations§
impl<S> !Freeze for StatementCache<S>
impl<S> !RefUnwindSafe for StatementCache<S>
impl<S> Send for StatementCache<S>where
S: Send,
impl<S> Sync for StatementCache<S>
impl<S> Unpin for StatementCache<S>where
S: Unpin,
impl<S> UnwindSafe for StatementCache<S>where
S: UnwindSafe,
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