gsh/runtime/store

The store module provides a lightweight, persistent key-value cache backed by the Erlang Process Dictionary.

In a standard file-backed REPL, every time the file is re-evaluated, all previous side-effects (like spawning processes or DB writes) would run again. GSH avoids this by wrapping every let binding in a cache check. This store ensures that variables are evaluated exactly once and kept alive in the VM’s memory across multiple REPL prompts.

Values

pub fn cache(key: String, compute: fn() -> a) -> a
pub fn put(key: String, value: a) -> a

Saves a value into the Process Dictionary under the given string key. Returns the saved value so it can be returned inline during evaluation.

Search Document