MCPcopy Create free account
hub / github.com/PostHog/duckgres / openFile

Method openFile

cmd/cache-proxy/cache.go:298–318  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 }

Callers 3

OpenMethod · 0.95
HandleProxyMethod · 0.80

Calls 4

touchLockedMethod · 0.95
IsValidCacheKeyFunction · 0.85
CloseMethod · 0.65
OpenMethod · 0.45

Tested by 1