Skip to main content

Module disk_offload

Module disk_offload 

Source
Expand description

Disk-payload offload decorator for CacheRepository backends.

DiskOffloadRepository wraps any backend (the “index”) and moves entry payloads to content-addressed blob files under a dedicated directory, storing only a relative file name in the index row. Index rows stay small; the payload is re-injected on get/peek_stale.

§Blob lifecycle

Blob names are {blake3-128hex(key)}.{death_epoch_secs}.{blake3-128hex( bytes || content_type-discriminant)}.blob. The death epoch — expires_at + stale_retention + sweep_interval — is encoded in the name so the background sweeper can reclaim dead blobs by file name alone, without consulting the index.

§Failure policy

  • A blob write that fails falls back to storing the entry inline in the index (WARN + inner.set with the original entry): the decorator never converts its own file-write failure into a cache-write Err.
  • A vanished or corrupt blob row degrades to a miss (Ok(None) + WARN).
  • A blob that exists but cannot be read (e.g. PermissionDenied) surfaces as Err per ADR-0023 Contract C1.

Structs§

DiskOffloadRepository
CacheRepository decorator that offloads entry payloads to disk.

Functions§

default_offload_clock
The default production clock: SystemTime::now.

Type Aliases§

OffloadClock
Injectable wall clock for death-epoch math and deterministic tests.