| 192 | // ─── Initialization ───────────────────────────────────────────────────── |
| 193 | |
| 194 | bool DiskPrefixCache::init() { |
| 195 | if (disabled()) return true; |
| 196 | |
| 197 | if (!mkdir_p(config_.cache_dir)) { |
| 198 | std::fprintf(stderr, "[disk-cache] failed to create dir: %s\n", |
| 199 | config_.cache_dir.c_str()); |
| 200 | return false; |
| 201 | } |
| 202 | |
| 203 | // Try to learn layout from existing files (enables first-request disk hits). |
| 204 | try_learn_from_disk(); |
| 205 | |
| 206 | std::fprintf(stderr, "[disk-cache] initialized dir=%s budget=%.1f GB layout=%s\n", |
| 207 | config_.cache_dir.c_str(), |
| 208 | (double)config_.budget_bytes / (1024.0 * 1024.0 * 1024.0), |
| 209 | layout_known_ ? hex(layout_id_.data(), 16).c_str() : "pending"); |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | // ─── Layout fingerprint ───────────────────────────────────────────────── |
| 214 |
no test coverage detected