Flicker.RecentValues.Ets (Flicker v0.1.0)

Copy Markdown View Source

A dev/test-only in-memory Flicker.RecentValues store (Spec 022).

Not durable, not shared across nodes, and gone on restart. It exists so the playground can demonstrate the Recent group and so tests have a real store to drive, not as something to point a production app at — see Flicker.RecentValues for why Flicker deliberately owns no persistence.

Usage

Flicker.RecentValues.Ets.start()

<Flicker.search
  recent_values={Flicker.RecentValues.Ets.config()}
  ...
/>

Entries are keyed by {scope, facet_key, value}, where scope is derived from the :actor in opts — so two actors in the same dev session don't see each other's history, mirroring what a real host's per-user storage would do.

Summary

Functions

Clears everything. Test support.

The recent_values config map to hand to a component.

Every recorded usage for facet_key in the caller's scope, as {value, used_at, count} triples.

Records one use of value, bumping its count and its timestamp.

Creates the backing table if it doesn't exist. Idempotent.

Functions

clear()

@spec clear() :: :ok

Clears everything. Test support.

config()

@spec config() :: %{load: function(), record: function()}

The recent_values config map to hand to a component.

load(facet_key, opts)

@spec load(atom(), keyword()) :: [Flicker.RecentValues.usage()]

Every recorded usage for facet_key in the caller's scope, as {value, used_at, count} triples.

Returns facts, not an opinion — Flicker.RecentValues.rank/2 does the ordering, so ranking stays one testable function rather than something each store reimplements.

record(facet_key, value, opts)

@spec record(atom(), term(), keyword()) :: :ok

Records one use of value, bumping its count and its timestamp.

start()

@spec start() :: :ok

Creates the backing table if it doesn't exist. Idempotent.