openFile opens a cached entry WITHOUT recording a hit. Used to serve a body that was just fetched on a miss — that path already counted a miss, so counting it as a hit too would double-count.
(key string)
| 296 | if dc.maxEntries > dc.hardMaxEntries { |
| 297 | dc.maxEntries = dc.hardMaxEntries |
| 298 | } |
| 299 | |
| 300 | startupContext := option.startupContext |
| 301 | if startupContext == nil { |
| 302 | startupContext = context.Background() |
| 303 | } |
| 304 | removedTemporaryFiles, err := resetTemporaryDirectory(startupContext, filepath.Join(dir, tmpSubdir)) |
| 305 | if err != nil { |
| 306 | return nil, fmt.Errorf("reset cache temp dir: %w", err) |
| 307 | } |
| 308 | if removedTemporaryFiles > 0 { |
| 309 | cacheTemporaryFilesRemovedTotal.Add(float64(removedTemporaryFiles)) |
| 310 | } |
| 311 | |
| 312 | // Complete enumeration and the exceptional hard-cap survivor pass before |
| 313 | // sampling free space. No soft-target deletion occurs during startup. |
| 314 | ownedBytes, err := dc.scanExistingContext(startupContext) |
| 315 | if err != nil { |
| 316 | return nil, fmt.Errorf("scan existing cache entries: %w", err) |
| 317 | } |
| 318 | startupSpace, err := dc.diskSpace() |
| 319 | if err != nil { |
| 320 | return nil, fmt.Errorf("statfs %s: %w", dir, err) |
| 321 | } |