Expand description
nitr.cache: a bounded, Rust-owned cache shared by every pooled state.
This is deliberately not a hole in the isolation model. Values are serialized on the way in and rebuilt on the way out, so no Lua value, function, or userdata ever crosses between states, and one state can never reach another’s heap through it. Rust owns the memory and the bound, so the cache cannot grow without limit. It is shared data, not shared state — the same relationship Lua already has with SQLite.
Two properties applications must know, because building on the opposite assumption fails quietly:
- It lives in the process. A restart empties it, and two Nitr processes behind a load balancer have two independent caches. Do not put sessions, locks, or counters that must be exact in here.
- It survives a reload. A cache that empties every time the handler script changes is a cache that never warms, which is worse than not having one in development.
Structs§
- Cache
- The shared cache. Cloning shares the same storage; the server builds one and hands it to every state.
- Cache
Options - Limits and defaults for the shared cache.