Skip to main content

Module cache

Module cache 

Source
Expand description

Binary columnar event cache.

This module implements the binary cache format described in docs/binary-cache-format.md. The cache is a derived, read-optimised representation of the TSJSON event log. It is not authoritative — the .events files are the source of truth — but enables sub-millisecond replay on large repositories.

§Module layout

§Usage sketch

use bones_core::cache::{CacheHeader, CacheColumns};

// Build from events and encode to bytes:
// let cols = CacheColumns::from_events(&events)?;
// let header = CacheHeader::new(events.len() as u64);
// let bytes = header.encode(&cols)?;

// Decode from bytes:
// let (header, cols) = CacheHeader::decode(&bytes)?;
// let events = cols.into_events()?;

Re-exports§

pub use codec::ColumnCodec;
pub use codec::EventTypeCodec;
pub use codec::InternedStringCodec;
pub use codec::ItemIdCodec;
pub use codec::RawBytesCodec;
pub use codec::TimestampCodec;
pub use codec::ValueCodec;
pub use columns::COLUMN_COUNT;
pub use columns::CacheColumns;
pub use columns::ColumnRow;
pub use manager::CacheManager;
pub use manager::LoadResult;
pub use manager::LoadSource;
pub use reader::CacheReader;
pub use reader::CacheReaderError;
pub use writer::CacheStats;
pub use writer::CacheWriter;
pub use writer::rebuild_cache;

Modules§

codec
Column codec trait and implementations for the binary cache format.
columns
Per-column type definitions for the binary event cache.
manager
Cache lifecycle management: freshness check, rebuild trigger, fallback.
reader
Binary cache file reader.
writer
File I/O helpers for the binary columnar cache.

Structs§

CacheHeader
File header for the binary event cache.

Enums§

CacheError
Errors returned by cache encoding and decoding.

Constants§

CACHE_MAGIC
The four magic bytes at the start of every cache file.
CACHE_VERSION
The current format version written to new cache files.
HEADER_SIZE
File header size in bytes (fixed).

Functions§

decode_events
Decode binary cache bytes back to a vector of events.
encode_events
Encode a slice of events to binary cache bytes.