pub struct Cache { /* private fields */ }Expand description
Node-level LRU cache for OCI module artifacts.
Cache layout: <root>/<module>/<version>/
Each entry directory contains extracted module content plus:
.cfgd-last-access— unix timestamp for LRU tracking.cfgd-complete— sentinel indicating successful extraction
LRU eviction uses the marker file (filesystem atime is unreliable with noatime/relatime mount options).
Implementations§
Source§impl Cache
impl Cache
pub fn new(root: PathBuf, max_bytes: u64) -> Result<Self, CsiError>
Sourcepub fn get_or_pull(
&self,
module: &str,
version: &str,
oci_ref: &str,
) -> Result<PathBuf, CsiError>
pub fn get_or_pull( &self, module: &str, version: &str, oci_ref: &str, ) -> Result<PathBuf, CsiError>
Return the cache path for a module, or pull it if not cached.
On cache hit, updates access time for LRU tracking. On cache miss, pulls the OCI artifact to a temp dir and atomically moves it into place (safe under concurrent access). After a pull, runs eviction if over capacity.
Sourcepub fn get(&self, module: &str, version: &str) -> Option<PathBuf>
pub fn get(&self, module: &str, version: &str) -> Option<PathBuf>
Return the cached path if it exists and is complete, without pulling.
Sourcepub fn evict_lru(&self) -> Result<(), CsiError>
pub fn evict_lru(&self) -> Result<(), CsiError>
Evict least-recently-used entries until cache is under max_bytes.
Sourcepub fn current_size_bytes(&self) -> u64
pub fn current_size_bytes(&self) -> u64
Total bytes used by cached entries (excludes marker files).
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request