ExSQL. Codegen. Cache
(exsql v0.1.13)
Copy Markdown
Shape-keyed cache + compile gate for ExSQL.Codegen.
Maps a query shape (the param-lifted IR — same shape for any literal values)
to either a sighting count or a compiled module. A shape is only compiled once
it has been seen threshold times (default 2): one-shot ad-hoc queries never
pay the compile cost, while repeated/prepared queries amortize it. The compiled
modules are global (a Module.create side effect), so the cache lives in a
:public ETS table owned by this process — like ExSQL.Registry.
Summary
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec fetch(term()) :: {:hit, module()} | {:compile, pos_integer()} | :too_few
Records a sighting of shape_key and decides what to do:
{:hit, module}— already compiled, run it.{:compile, n}— seen enough times; the caller should compile +store/2.:too_few— not seen enough yet; fall back to the tree walker this time.
Stores the compiled module for a shape (subsequent fetch/1 returns {:hit, module}).