Skip to main content

Module mem_cache

Module mem_cache 

Source
Expand description

Read-mem cache resolution, published-config reads, and the install-to-cache side effect.

Every sealed-archive byte entering the cache goes through validate_and_normalize_archive — the install path reads the submitted archive, hands the bytes to the validator, and writes the validator’s canonical_bytes via a temp-plus-atomic-rename so no partial archive ever lands on disk. Steady-state loads (through read_published_config or the entity loader) trust the cached bytes: they were canonical at write time and re-validation on every load would just pay for the same work twice.

The cache base path resolves via dirs::data_dir() so the same path works on macOS (~/Library/Application Support/memstead/mems), Linux ($XDG_DATA_HOME/memstead/mems or ~/.local/share/memstead/mems), and Windows (%APPDATA%\memstead\mems). For tests, MEMSTEAD_MEM_CACHE overrides the base so temp dirs can stand in without touching the user’s real data directory.

Structs§

InstallOutcome
Outcome of an install_read_mem call — captured so callers can log what actually happened without re-deriving it from side effects.

Enums§

InstallError
SchemaExtractionError
SchemaExtractionOutcome
Outcome of extract_archive_schema_if_needed — so callers can log the specific reason a no-op happened, or know whether the mem’s schema registry needs to be rebuilt.
TargetMem
Where the per-mem readMems registration should land.

Constants§

CACHE_OVERRIDE_ENV
Env var that overrides <data_dir>/memstead/mems for tests.

Functions§

extract_archive_schema_if_needed
Extract the schema embedded in archive_path into the writable mem’s cache, but only when the pinned (name, version) is not already registered.
install_read_mem
Install a sealed mem archive into the global cache and register it in a writable mem’s config. Accepts the .mem archive format.
mem_cache_dir
Resolve the global mem-cache directory.
read_published_config
Read the whitelisted .memstead/config.json from a cached archive.