Skip to main content

CacheIndex

Struct CacheIndex 

Source
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

Source

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.

Source

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).

Source

pub fn record_blob(&self, key: &str, size: u64)

Record a cached LFS object with its exact size and wake the background task in case the cache is now over cap. Unlike a mirror, an object is immutable and its size is known at store time, so it needs no deferred measurement - it goes straight into the index at its final size and is promoted to most-recently-used.

Source

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.

Source

pub fn cache_dir(&self, name: &str) -> PathBuf

On-disk path of a tracked mirror.

Source

pub fn totals(&self) -> (u64, usize)

Current (total_bytes, mirror_count) - the values mirrored to the gauges.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more