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

Function getCacheKey

packages/next/src/server/config.ts:1493–1513  ·  view source on GitHub ↗
(
  phase: PHASE_TYPE,
  dir: string,
  customConfig?: object | null,
  reactProductionProfiling?: boolean,
  debugPrerender?: boolean,
  pid?: number
)

Source from the content-addressed store, hash-verified

1491// Generate cache key based on parameters that affect config output
1492// We need a unique key for cache because there can be multiple values
1493function getCacheKey(
1494 phase: PHASE_TYPE,
1495 dir: string,
1496 customConfig?: object | null,
1497 reactProductionProfiling?: boolean,
1498 debugPrerender?: boolean,
1499 pid?: number
1500): string {
1501 // The next.config.js is unique per project, so we can use the dir as the major key
1502 // to generate the unique config key. Include PID to invalidate on server restart.
1503 const keyData = JSON.stringify({
1504 dir,
1505 phase,
1506 hasCustomConfig: Boolean(customConfig),
1507 reactProductionProfiling: Boolean(reactProductionProfiling),
1508 debugPrerender: Boolean(debugPrerender),
1509 pid: pid || 0,
1510 })
1511
1512 return djb2Hash(keyData).toString(36)
1513}
1514
1515type LoadConfigOptions = {
1516 customConfig?: object | null

Callers 3

storeResultMethod · 0.85
applyMethod · 0.85
loadConfigFunction · 0.85

Calls 3

djb2HashFunction · 0.90
stringifyMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…