Skip to main content

agentmux_srv/backend/storage/filestore/
cache.rs

1// Copyright 2025, Command Line Inc.
2// Copyright 2025-2026, AgentMux Corp.
3// SPDX-License-Identifier: Apache-2.0
4
5//! Internal cache structs for FileStore.
6
7
8use std::collections::HashMap;
9
10use super::types::MuxFile;
11
12/// Cache entry for file data parts.
13#[derive(Debug, Clone)]
14pub(super) struct DataCacheEntry {
15    #[allow(dead_code)]
16    pub(super) part_idx: i32,
17    #[allow(dead_code)]
18    pub(super) data: Vec<u8>,
19}
20
21/// Cache entry for a file + its data parts.
22#[derive(Debug)]
23pub(super) struct CacheEntry {
24    pub(super) file: Option<MuxFile>,
25    #[allow(dead_code)]
26    pub(super) data_entries: HashMap<i32, DataCacheEntry>,
27    #[allow(dead_code)]
28    pub(super) dirty: bool,
29    /// Last time this entry was read or written (ms since epoch).
30    /// Used for TTL-based eviction of clean entries.
31    pub(super) last_access_ms: i64,
32    /// Byte size charged to the LRU cap for this entry.
33    /// Approximates `file.size` at insertion time; updated on write.
34    pub(super) cached_size_bytes: usize,
35}