Macaw.Live.Renders.Memory (macaw_live v0.1.0)

Copy Markdown View Source

The render memo's default (spec/01 §3.4): an ETS table its process owns, started under the host's Macaw.Live.Supervisor as <live>.Renders, so the table is the supervisor's. It holds at most entries: renders (10,000) and bytes: bytes of markup (256 MiB), dropping the oldest past either; a render larger than bytes: is never held. Reads go to the table directly and send nothing; writes go through the process. The markup is held as the binaries the proof wrote, so a read copies their references.

The oldest is dropped, not the least recently read: a render is keyed by its inputs' versions, so a change leaves the old keys unread and they age out first, and a read costs no message.

Its rows are indexed by scope and viewer (rows/3): each row it holds under a row key (Macaw.Live.Renders.row_key/4) is also in an ordered table by the digest of its scope and viewer and its version, so the rows of one scope are read by a range of that table, never a scan of the memo. Dropping the row drops its index entry.

Summary

Functions

Its child spec: name: (required, the table's name too), entries: and bytes:.

Starts the memo: name:, an atom, required; entries: (10,000) and bytes: (268,435,456), positive integers. {:ok, pid}, or {:error, faults}: {[:name], :required}, {[key], {:type, :pos_integer}}.

Functions

child_spec(init_arg)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Its child spec: name: (required, the table's name too), entries: and bytes:.

start_link(opts)

@spec start_link(keyword()) ::
  GenServer.on_start() | {:error, [Macaw.Base.Fault.t(), ...]}

Starts the memo: name:, an atom, required; entries: (10,000) and bytes: (268,435,456), positive integers. {:ok, pid}, or {:error, faults}: {[:name], :required}, {[key], {:type, :pos_integer}}.