#[non_exhaustive]pub enum FactTableVersionStrategy {
Disabled,
VersionTable,
TimeBased {
ttl_seconds: u64,
},
SchemaVersion,
}Expand description
Versioning strategy for fact table aggregation caching.
Different strategies offer different trade-offs between cache hit rate, data freshness, and operational complexity.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Disabled
No caching for aggregations (always query database).
Use when: Real-time accuracy is required. Trade-off: No caching benefit, every query hits database.
VersionTable
Read version from tf_versions table.
Cache key includes the version number, so when version bumps, old cache entries are automatically ignored.
Use when: Data is loaded via ETL/batch processes that can bump versions. Trade-off: Requires discipline to bump version after data changes.
§Version Bumping
After loading data, call:
SELECT bump_tf_version('tf_sales');Or use triggers for automatic bumping (adds write overhead).
TimeBased
Time-based TTL caching.
Cache entries expire after the specified duration regardless of whether the underlying data has changed.
Use when: Some staleness is acceptable (e.g., dashboards). Trade-off: May serve stale data within TTL window.
SchemaVersion
Use schema version only (invalidate on deployment).
Cache is only invalidated when the schema version changes, which typically happens during deployments.
Use when: Fact table data is immutable or append-only and queries always filter to recent data. Trade-off: Stale data until next deployment.
Implementations§
Source§impl FactTableVersionStrategy
impl FactTableVersionStrategy
Sourcepub const fn time_based(ttl_seconds: u64) -> Self
pub const fn time_based(ttl_seconds: u64) -> Self
Create a time-based strategy with the given TTL.
Sourcepub const fn is_caching_enabled(&self) -> bool
pub const fn is_caching_enabled(&self) -> bool
Check if caching is enabled for this strategy.
Sourcepub const fn ttl_seconds(&self) -> Option<u64>
pub const fn ttl_seconds(&self) -> Option<u64>
Get TTL for time-based strategy, if applicable.
Trait Implementations§
Source§impl Clone for FactTableVersionStrategy
impl Clone for FactTableVersionStrategy
Source§fn clone(&self) -> FactTableVersionStrategy
fn clone(&self) -> FactTableVersionStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FactTableVersionStrategy
impl Debug for FactTableVersionStrategy
Source§impl Default for FactTableVersionStrategy
impl Default for FactTableVersionStrategy
Source§impl<'de> Deserialize<'de> for FactTableVersionStrategy
impl<'de> Deserialize<'de> for FactTableVersionStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for FactTableVersionStrategy
impl PartialEq for FactTableVersionStrategy
Source§impl Serialize for FactTableVersionStrategy
impl Serialize for FactTableVersionStrategy
impl Eq for FactTableVersionStrategy
impl StructuralPartialEq for FactTableVersionStrategy
Auto Trait Implementations§
impl Freeze for FactTableVersionStrategy
impl RefUnwindSafe for FactTableVersionStrategy
impl Send for FactTableVersionStrategy
impl Sync for FactTableVersionStrategy
impl Unpin for FactTableVersionStrategy
impl UnsafeUnpin for FactTableVersionStrategy
impl UnwindSafe for FactTableVersionStrategy
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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