class

Hwaro::Core::Build::CacheManager

Inherits Reference / Object

Constructors

Instance methods

all_stats

Return a snapshot of all layer stats as an array of named tuples.

Source
clear(*names : String, reset_stats : Bool = true)

Clear specific named caches. Pass reset_stats: false to preserve hit/miss counters across clears (useful for streaming batch clears where stats should span the whole build).

Source
clear_all(reset_stats : Bool = true)

Clear all registered caches (both runtime and persistent). Pass reset_stats: false to preserve hit/miss counters (e.g. for memory-management clears where you still want end-of-build reporting).

Source
clear_runtime(reset_stats : Bool = true)

Clear only runtime (in-memory) caches, preserving persistent caches. Pass reset_stats: false to preserve hit/miss counters.

Source
record_hit(name : String)

Record a cache hit for the named layer.

Deliberately lock-free: the counters are Atomics precisely so hot render paths don't serialize on @mutex (record_hit/record_miss run several times per page from parallel fibers). The bare @layers read is safe because layers are registered once during Builder construction, before any parallel phase mutates or reads stats.

Source
record_miss(name : String)

Record a cache miss for the named layer. Lock-free — see record_hit.

Source
register(name : String, description : String, runtime : Bool = true, &clear : -> Nil)

Register a cache layer with the manager. runtime: true for per-build in-memory caches, false for persistent (file-based) caches.

Source
registered?(name : String) : Bool

Check if a layer is registered.

Source
report

Log cache stats summary. Only logs layers that had activity.

Source
report_verbose

Verbose report with all layers (including inactive ones).

Source
reset_stats

Reset all hit/miss counters without clearing cache contents.

Source
size

Number of registered layers.

Source
stats_for(name : String) : NamedTuple(hits: Int64, misses: Int64, hit_rate: Float64) | Nil

Get an immutable stats snapshot for a specific cache layer.

Source

Nested types