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§
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 more