pub struct CacheIndex { /* private fields */ }Expand description
In-memory record of the on-disk mirror cache, plus the eviction trigger. Shared
(via Arc) between the GitCache that mutates it on clone/fetch/serve and the
background task in run that measures and evicts.
Implementations§
Source§impl CacheIndex
impl CacheIndex
Sourcepub fn new(
cache_root: PathBuf,
max_bytes: u64,
metrics: Arc<Metrics>,
) -> Arc<Self> ⓘ
pub fn new( cache_root: PathBuf, max_bytes: u64, metrics: Arc<Metrics>, ) -> Arc<Self> ⓘ
Build the index by scanning cache_root once. Seeds access order from each
mirror’s newest file mtime (oldest first, so the oldest lands at the LRU
tail), so recency roughly survives a restart. Blocking, but runs at startup
before the server binds.
Sourcepub fn touch(&self, name: &str)
pub fn touch(&self, name: &str)
Mark a repo used. Serving does not grow the cache, so this never wakes the
evictor; it only keeps the access order honest. No-op for a repo not yet
tracked (its first clone tracks it via mark_changed).
Sourcepub fn mark_changed(&self, name: &str)
pub fn mark_changed(&self, name: &str)
Flag a mirror as changed after a clone/fetch: promote it (it was just used), schedule it for measurement, and wake the background task. O(1) bookkeeping only - the size walk happens off the request path.