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

Function writeEntry

test/unit/image-optimizer/lru-disk-eviction.test.ts:11–21  ·  view source on GitHub ↗
(
  cacheDir: string,
  key: string,
  sizeInBytes: number,
  expireAt: number = Date.now() + 60_000
)

Source from the content-addressed store, hash-verified

9} from 'next/dist/server/lib/disk-lru-cache.external'
10
11async function writeEntry(
12 cacheDir: string,
13 key: string,
14 sizeInBytes: number,
15 expireAt: number = Date.now() + 60_000
16) {
17 const dir = join(cacheDir, key)
18 const buffer = Buffer.alloc(sizeInBytes, 0x42) // Fill with dummy data
19 await promises.mkdir(dir, { recursive: true })
20 await promises.writeFile(join(dir, `${expireAt}.bin`), buffer)
21}
22
23async function readEntry(cacheDir: string, key: string) {
24 const dir = join(cacheDir, key)

Callers 1

Calls 4

joinFunction · 0.90
mkdirMethod · 0.80
writeFileMethod · 0.65
nowMethod · 0.45

Tested by

no test coverage detected