Spectre.Router.SemanticCache.Learned.Online (Spectre v0.3.0)

Copy Markdown View Source

ETS-backed store for online learned semantic-cache examples.

Owns the public named tables holding mutable online rows and their per-agent monotonic revisions. Table names are part of the operational contract: this module's own name is the online table and Learned.Revisions holds the counters, both created through the supervised semantic-cache owner.

Summary

Functions

Advances the agent's online revision counter.

Deletes every online row of one agent.

Deletes one online row.

Fetches one online row, or nil.

Finds the agent's online row with the given normalized text, or nil.

Fetches an editable online row, distinguishing read-only and missing ids.

Stores or replaces one online row under its agent and id.

Returns the monotonic in-memory revision of an agent's online examples.

Returns the agent's online rows visible under the cacheable rules.

Functions

bump_revision(agent)

@spec bump_revision(module()) :: non_neg_integer()

Advances the agent's online revision counter.

clear_rows(agent)

@spec clear_rows(module()) :: :ok

Deletes every online row of one agent.

delete_row(agent, id)

@spec delete_row(module(), String.t()) :: :ok

Deletes one online row.

fetch(agent, id)

Fetches one online row, or nil.

find_by_normalized(agent, normalized)

@spec find_by_normalized(module(), String.t()) ::
  Spectre.Router.SemanticCache.Learned.row() | nil

Finds the agent's online row with the given normalized text, or nil.

mutable_row(agent, id, opts)

@spec mutable_row(module(), String.t(), keyword()) ::
  {:ok, Spectre.Router.SemanticCache.Learned.row()} | {:error, term()}

Fetches an editable online row, distinguishing read-only and missing ids.

put_row(row, opts \\ [])

@spec put_row(
  Spectre.Router.SemanticCache.Learned.row(),
  keyword()
) :: :ok

Stores or replaces one online row under its agent and id.

revision(agent)

@spec revision(module()) :: non_neg_integer()

Returns the monotonic in-memory revision of an agent's online examples.

rows(agent, opts)

Returns the agent's online rows visible under the cacheable rules.