Skip to main content

Module rotation

Module rotation 

Source
Expand description

LRU rotation / eviction policy for the asset cache.

The rotator is stateless: every call evaluates the index and deletes whichever assets need to go based on the configured EvictionPolicy and size / age limits.

Eviction priority for LRU:

  1. Assets older than max_file_age (by last_accessed) are removed unconditionally. This implements the TTL behaviour described in the ADR.
  2. If the remaining cache is still over max_cache_size, assets are removed in LRU order (oldest last_accessed first) until the budget is met. Within the same timestamp bucket, larger files go first so one multi-GB video is preferred over many small logs.

Structs§

RotationStats
Stats produced by a rotation pass — exposed so callers can log what happened and tests can assert on side-effects.
Rotator
Applies an EvictionPolicy to an AssetIndex + cache root.