Caching#
simulate_cached() memoizes recordings to disk, keyed by
spec.cache_key(). These helpers locate that cache.
simulate_cached#
- minisim.simulate_cached(spec, *, root=None)[source]#
Return the recording for
spec, loading from cache or simulating on a miss.- Parameters:
spec (Spec) – The recording spec; its
cache_keyis the cache key.root (str | Path | None) – Cache directory. Defaults to
cache_dir()($MINISIM_CACHEor~/.cache/minisim).
- Return type:
Notes
The cache is keyed by filename (
{cache_key}.zarr): a changed spec serializes to a new key, hence a new filename and a clean miss, so the cache never serves a recording for the wrong spec. A hit is served byRecording.load(); a miss runssimulate()and persists the result withRecording.save()before returning it.
cache_dir#
- minisim.cache_dir()[source]#
The resolved cache root:
$MINISIM_CACHEif set, elseDEFAULT_CACHE_DIR.The returned path is user-expanded (
~) but not created -simulate_cached()makes it on first write.- Return type: