Skip to main content

Module cache

Module cache 

Source
Expand description

Cache Module

High-performance caching infrastructure for RedDB.

§Components

  • sieve: SIEVE page cache for database pages (O(1) operations)
  • blob: Byte-oriented L1 cache for exact-key cached blobs
  • result: Query result cache with dependency-based invalidation
  • aggregates: Precomputed aggregations (COUNT, SUM, AVG, etc.)
  • spill: Graph spill-to-disk for memory-limited environments

§Architecture (inspired by Turso/Milvus/Neo4j)

┌────────────────────────────────────────────────────────┐
│                    Query Layer                         │
├────────────────────────────────────────────────────────┤
│  Result Cache   │  Materialized Views  │  Plan Cache   │
├────────────────────────────────────────────────────────┤
│           Aggregation Cache (COUNT/SUM/AVG)            │
├────────────────────────────────────────────────────────┤
│   SIEVE Page Cache    │     Spill Manager              │
├────────────────────────────────────────────────────────┤
│                   Storage Engine                       │
└────────────────────────────────────────────────────────┘

Re-exports§

pub use aggregates::AggCacheStats;
pub use aggregates::AggValue;
pub use aggregates::AggregationCache;
pub use aggregates::CardinalityEstimate;
pub use aggregates::NumericAgg;
pub use blob::BlobCache;
pub use blob::BlobCacheConfig;
pub use blob::BlobCacheHit;
pub use blob::BlobCachePolicy;
pub use blob::BlobCachePut;
pub use blob::BlobCacheStats;
pub use blob::CacheError;
pub use blob::L1Admission;
pub use blob::L2Compression;
pub use blob::DEFAULT_BLOB_L1_BYTES_MAX;
pub use blob::DEFAULT_BLOB_L2_BYTES_MAX;
pub use blob::DEFAULT_BLOB_MAX_NAMESPACES;
pub use blob::METRIC_CACHE_BLOB_L1_BYTES_IN_USE;
pub use blob::METRIC_CACHE_BLOB_L2_BYTES_IN_USE;
pub use blob::METRIC_CACHE_BLOB_L2_FULL_REJECTIONS_TOTAL;
pub use blob::METRIC_CACHE_VERSION_MISMATCH_TOTAL;
pub use compressor::CompressError;
pub use compressor::CompressOpts;
pub use compressor::Compressed;
pub use compressor::L2BlobCompressor;
pub use extended_ttl::EffectiveExpiry;
pub use extended_ttl::ExpiryDecision;
pub use extended_ttl::ExtendedTtlPolicy;
pub use promotion_pool::AsyncPromotionPool;
pub use promotion_pool::PoolOpts;
pub use promotion_pool::PromotionExecutor;
pub use promotion_pool::PromotionMetrics;
pub use promotion_pool::PromotionRequest;
pub use promotion_pool::ScheduleOutcome;
pub use result::CacheKey;
pub use result::CachePolicy;
pub use result::MaterializedViewCache;
pub use result::MaterializedViewDef;
pub use result::RefreshPolicy;
pub use result::ResultCache;
pub use result::ResultCacheStats;
pub use ring::BufferRing;
pub use sieve::CacheConfig;
pub use sieve::CacheStats;
pub use sieve::PageCache;
pub use sieve::PageId;
pub use spill::SpillConfig;
pub use spill::SpillError;
pub use spill::SpillManager;
pub use spill::SpillStats;
pub use spill::SpillableGraph;
pub use strategy::BufferAccessStrategy;

Modules§

aggregates
Aggregation Cache
bgwriter
Background writer task — Post-MVP credibility item.
blob
Byte-oriented Blob Cache.
compressor
L2 Blob Compressor.
extended_ttl
Extended TTL Policy & Effective Expiry
promotion_pool
Async promotion pool — turbo module for off-CPU L1 cache promotion.
result
Query Result Cache
ring
Fixed-size circular page ring used by super::strategy::BufferAccessStrategy.
sieve
SIEVE Page Cache
spill
Graph Spill Manager
strategy
Buffer access strategies for the page cache.
sweeper
Bounded Blob Cache sweeper — admin maintenance for L1 expirations and L2 orphan-chain reclamation.

Functions§

archive_blob_cache_l2
Archive the L2 pager file + control sidecar to backend under {prefix}l2.pager and {prefix}l2.ctl. Returns the number of files uploaded (0..=2).
restore_blob_cache_l2
Restore the L2 pager file + control sidecar from backend’s {prefix}l2.pager and {prefix}l2.ctl keys into l2_path (and its <l2_path>.blob-cache.ctl sibling). Returns the number of files downloaded.