Skip to main content

Module cache

Module cache 

Source
Expand description

Lazy generation cache for .wasm modules.

Two kinds of artefacts land here:

  1. Per-source compilations — e.g. a Rust snippet → WASM goes into runtimes/rust/<source-hash>.wasm. Idempotent: same source text never recompiles.
  2. Drop-in interpreters — once Steel-WASM / QuickJS-wasi ship, a user can place runtimes/<lang>.wasm here and the registry discovers it (M2 follow-up).

Path resolution:

  • Linux/BSD → $XDG_CACHE_HOME/outl/runtimes/ or ~/.cache/outl/runtimes/
  • macOS → ~/Library/Caches/outl/runtimes/
  • Windows → %LOCALAPPDATA%\outl\runtimes\

Delegated to the dirs crate so we follow OS conventions instead of hard-coding paths.

Functions§

cache_dir
Root cache directory: <os cache>/outl/runtimes/.
cache_path_for_source
Path where a compiled artefact for (language, source) should land. The filename is <sha256-of-source>.wasm; collisions are vanishingly unlikely and the hash also doubles as a cache key for “is this source the same as last time?”.
is_fresh
Does the file at path exist and is non-empty? Used by lazy-gen runtimes to decide “skip the compile, just read the bytes”.