Configuration for a fingerprint cache instance. Attributes: name: Unique identifier for this cache (e.g., "cpp_lint", "python_test") cache_type: Type of cache to use cache_dir: Base directory for all caches (typically .cache/) build_mode: Optional build mode
| 45 | |
| 46 | @dataclass |
| 47 | class CacheConfig: |
| 48 | """ |
| 49 | Configuration for a fingerprint cache instance. |
| 50 | |
| 51 | Attributes: |
| 52 | name: Unique identifier for this cache (e.g., "cpp_lint", "python_test") |
| 53 | cache_type: Type of cache to use |
| 54 | cache_dir: Base directory for all caches (typically .cache/) |
| 55 | build_mode: Optional build mode (for build-dependent caches) |
| 56 | timestamp_file: Optional path to write change timestamps |
| 57 | description: Human-readable description of what this cache tracks |
| 58 | """ |
| 59 | |
| 60 | name: str |
| 61 | cache_type: CacheType |
| 62 | cache_dir: Path |
| 63 | build_mode: Optional[BuildMode] = None |
| 64 | timestamp_file: Optional[Path] = None |
| 65 | description: str = "" |
| 66 | |
| 67 | def get_cache_filename(self) -> str: |
| 68 | """ |
| 69 | Get the cache filename for this configuration. |
| 70 | |
| 71 | Build-mode-dependent caches include the build mode in the filename |
| 72 | to prevent cache conflicts when switching modes. |
| 73 | |
| 74 | Returns: |
| 75 | Cache filename (e.g., "cpp_test_quick.json", "python_lint.json") |
| 76 | """ |
| 77 | if self.build_mode is not None: |
| 78 | return f"{self.name}_{self.build_mode.value}.json" |
| 79 | return f"{self.name}.json" |
| 80 | |
| 81 | def get_cache_path(self) -> Path: |
| 82 | """ |
| 83 | Get the full path to the cache file. |
| 84 | |
| 85 | Returns: |
| 86 | Full path to cache file in fingerprint directory |
| 87 | """ |
| 88 | return self.cache_dir / "fingerprint" / self.get_cache_filename() |
| 89 | |
| 90 | def supports_build_modes(self) -> bool: |
| 91 | """ |
| 92 | Check if this cache supports build mode separation. |
| 93 | |
| 94 | Returns: |
| 95 | True if cache supports per-mode caching |
| 96 | """ |
| 97 | return self.build_mode is not None |
| 98 | |
| 99 | |
| 100 | # ============================================================================== |