agentmux_srv\backend\storage\filestore/
cache.rs

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