MCPcopy
hub / github.com/vercel/next.js / initEntries

Function initEntries

test/unit/image-optimizer/lru-disk-eviction.test.ts:31–44  ·  view source on GitHub ↗
(
  cacheDir: string
)

Source from the content-addressed store, hash-verified

29}
30
31async function initEntries(
32 cacheDir: string
33): Promise<Array<{ key: string; size: number; expireAt: number }>> {
34 const keys = await promises.readdir(cacheDir).catch(() => [])
35 const entries: Array<{ key: string; size: number; expireAt: number }> = []
36
37 for (const key of keys) {
38 const { size, expireAt } = await readEntry(cacheDir, key)
39 entries.push({ key, size, expireAt })
40 }
41
42 // Sort oldest-first so we can replay them chronologically into LRU
43 return entries.sort((a, b) => a.expireAt - b.expireAt)
44}
45
46async function rmEntry(cacheDir: string, cacheKey: string): Promise<void> {
47 await promises.rm(join(cacheDir, cacheKey), {

Callers

nothing calls this directly

Calls 4

readEntryFunction · 0.85
pushMethod · 0.65
catchMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected