( cacheDir: string, key: string, sizeInBytes: number, expireAt: number = Date.now() + 60_000 )
| 9 | } from 'next/dist/server/lib/disk-lru-cache.external' |
| 10 | |
| 11 | async 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 | |
| 23 | async function readEntry(cacheDir: string, key: string) { |
| 24 | const dir = join(cacheDir, key) |
no test coverage detected