Barograph.SeriesCache (barograph v0.2.0)

Copy Markdown View Source

ETS cache mapping {metric, labels_hash} to series_id (spec §7.4).

The write path must never join to resolve a series. The table is :public with read_concurrency: true so the writer and future read pool can look up series without serialising through this process; the GenServer exists only to own the table and register its tid.

Summary

Functions

Returns a specification to start this module under a supervisor.

Looks up the series id for a metric and 16-byte labels hash.

Caches a series id under its metric and labels hash.

Returns the ETS tid for a database's series cache.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

lookup(tid, metric, labels_hash)

@spec lookup(:ets.tid(), String.t(), binary()) :: {:ok, integer()} | :miss

Looks up the series id for a metric and 16-byte labels hash.

put(tid, metric, labels_hash, series_id)

@spec put(:ets.tid(), String.t(), binary(), integer()) :: true

Caches a series id under its metric and labels hash.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

table(db)

@spec table(Barograph.db()) :: :ets.tid() | nil

Returns the ETS tid for a database's series cache.