Raxol. Performance. Caches. CacheHelper
(Raxol v2.6.0)
View Source
Shared cache get-or-compute pattern and telemetry for performance caches.
Eliminates the repeated pattern of checking ETS cache, emitting hit/miss telemetry, computing on miss, and storing the result.
Summary
Functions
Gets a value from cache or computes and caches it.
Emits a telemetry event with a standard %{count: 1} measurement.
Functions
Gets a value from cache or computes and caches it.
On cache hit, emits a :hit telemetry event and returns the cached value.
On cache miss, emits a :miss event, calls compute_fn, caches the result,
and returns it.
Parameters
key- The cache key stringtelemetry_prefix- e.g.[:raxol, :performance, :font_metrics_cache]telemetry_metadata- e.g.%{key_type: :char_width}compute_fn- Zero-arity function that computes the value on miss
Emits a telemetry event with a standard %{count: 1} measurement.