What it does
cache
Deprecated shim — re-exports Z.dataSource. Tabs created before the
dataSource extraction continue to call
Cache.tracked(key, fn, ttl, gate); new code should use
Z.dataSource(fn, { ttl, gate, key }) directly. Slated for removal
once every tab migrates.
Exports
M.tracked(key: string, fetchFn: () -> any, ttl: number?, gateFn: (() -> boolean)?) -> () -> any— build a tracked fetch closure (returns a function, not a source object, for backwards compatibility).M.invalidate(key: string)— drop the cached value for one key.M.reset()— drop every cached value in the registry.M._seedForTest/M._peekForTest— legacy test hooks delegated toZ.dataSource's registry.
Usage
local Cache = require("@builtin::modules.engine.editor.system_tools.cache")
local read = Cache.tracked("entities", function()
return query.entities()
end, 0.5)
local data = read()
Cache.invalidate("entities")
Notes
- This module owns no state of its own — everything routes through
Z.dataSource. Hot-reloading the shim is a no-op for cache contents. - The shim returns a closure, not a
Z.dataSourcehandle, so callers cannot reach into the underlying source. New tabs should preferZ.dataSourcedirectly for full control (gate, key, refresh hooks).
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.