rs_claude_bar/cache/
cache_manager.rs1use crate::cache::{load_cache, save_cache, set_file_info, refresh_cache, CacheInfo};
2
3pub struct CacheManager {
4 cache: CacheInfo,
5 base_path: String,
6}
7
8impl CacheManager {
9 pub fn new(base_path: &str, no_cache: bool) -> Self {
10 let cache = match no_cache {
11 true => CacheInfo::default(),
12 false => load_cache(),
13 };
14 let mut cm = Self { cache, base_path: base_path.to_string() };
15 cm.set_file_info();
16
17 cm
18 }
19
20 pub fn set_file_info(&mut self) {
21 set_file_info(&mut self.cache, &self.base_path);
22 }
23
24 pub fn get_cache(&self) -> &CacheInfo {
25 &self.cache
26 }
27
28 pub fn save(&self) {
29 save_cache(&self.cache);
30 }
31
32 pub fn refresh_cache(&mut self) {
35 refresh_cache(&mut self.cache, &self.base_path);
36 }
37}
38
39impl Drop for CacheManager {
40 fn drop(&mut self) {
41 }
43}