Caching#

simulate_cached() memoizes recordings to disk, keyed by spec.cache_key(). These helpers locate that cache.

simulate_cached#

.. py:function:: simulate_cached(spec, *, root=None) :module: minisim

Return the recording for spec, loading from cache or simulating on a miss.

:param spec: The recording spec; its :attr:~minisim.spec.Spec.cache_key is the cache key. :param root: Cache directory. Defaults to :func:cache_dir ($MINISIM_CACHE or ~/.cache/minisim).

.. rubric:: Notes

A hit is served by :meth:Recording.load, which re-verifies the stored spec hash; a miss runs :func:simulate and persists the result with :meth:Recording.save before returning it.

cache_dir#

.. py:function:: cache_dir() :module: minisim

The resolved cache root: $MINISIM_CACHE if set, else :data:DEFAULT_CACHE_DIR.

The returned path is user-expanded (~) but not created - :func:simulate_cached makes it on first write.

cache_path#

.. py:function:: cache_path(spec, root=None) :module: minisim

The on-disk path a recording for spec is cached at: {root}/{cache_key}.zarr.