1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/// DAG cache strategy for dependency graph analysis results.
///
/// Caches dependency graphs with intelligent invalidation based on source file
/// modification times. Uses a conservative approach that invalidates the cache
/// if any tracked files have been modified recently.
///
/// # Cache Characteristics
///
/// - **TTL**: 3 minutes
/// - **Max Size**: 20 entries (DAGs can be large)
/// - **Key**: Project path + DAG type
/// - **Validation**: No recent file modifications detected
///
/// # Examples
///
/// ```rust,no_run
/// use pmat::services::cache::strategies::DagCacheStrategy;
/// use pmat::services::cache::base::CacheStrategy;
/// use pmat::models::dag::DependencyGraph;
/// use pmat::cli::DagType;
/// use std::path::PathBuf;
/// use std::collections::HashMap;
/// use tempfile::tempdir;
///
/// let strategy = DagCacheStrategy;
/// let dir = tempdir().expect("tempdir");
/// let key = (dir.path().to_path_buf(), DagType::CallGraph);
///
/// // Generate cache key
/// let cache_key = strategy.cache_key(&key);
/// assert!(cache_key.starts_with("dag:"));
/// assert!(cache_key.contains("CallGraph"));
///
/// // Create a dummy dependency graph
/// let dag = DependencyGraph {
/// nodes: rustc_hash::FxHashMap::default(),
/// edges: vec![],
/// };
///
/// // Validation depends on file modification times
/// let is_valid = strategy.validate(&key, &dag);
/// // Result depends on actual file system state
///
/// // TTL should be 3 minutes
/// assert_eq!(strategy.ttl().expect("has ttl").as_secs(), 180);
/// assert_eq!(strategy.max_size(), 20);
/// ```
/// Check if a file was modified within the last 2 seconds