Persist cache to disk.
(self)
| 114 | self._data = {} |
| 115 | |
| 116 | def _save(self) -> None: |
| 117 | """Persist cache to disk.""" |
| 118 | if not self._enabled: |
| 119 | return |
| 120 | try: |
| 121 | _CACHE_DIR.mkdir(parents=True, exist_ok=True) |
| 122 | with open(_CACHE_FILE, "w") as f: |
| 123 | json.dump(self._data, f, separators=(",", ":")) |
| 124 | except OSError: |
| 125 | pass # Non-fatal |
| 126 | |
| 127 | def get(self, file_path: Path, compiler_args_key: str) -> list[str] | None: |
| 128 | """Look up cached IWYU result for a file. |