Unverified Commit eaf467e9 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update loading cache handler (#71121)

This just allows loading cache handler via global symbol instead of just
env or `next.config`.
parent 1235199d
import type { CacheHandler } from '../lib/incremental-cache'
export function getBuiltinRequestContext():
| BuiltinRequestContextValue
| undefined {
......@@ -27,5 +29,8 @@ export type BuiltinRequestContext = {
get(): BuiltinRequestContextValue | undefined
}
export type BuiltinRequestContextValue = { waitUntil?: WaitUntil }
export type BuiltinRequestContextValue = {
waitUntil?: WaitUntil
NextCacheHandler?: typeof CacheHandler
}
export type WaitUntil = (promise: Promise<any>) => void
......@@ -23,6 +23,7 @@ import {
} from '../../../lib/constants'
import { toRoute } from '../to-route'
import { SharedRevalidateTimings } from './shared-revalidate-timings'
import { getBuiltinRequestContext } from '../../after/builtin-request-context'
export interface CacheHandlerContext {
fs?: CacheFs
......@@ -120,6 +121,13 @@ export class IncrementalCache implements IncrementalCacheType {
}) {
const debug = !!process.env.NEXT_PRIVATE_DEBUG_CACHE
this.hasCustomCacheHandler = Boolean(CurCacheHandler)
const globalCacheHandler = getBuiltinRequestContext()?.NextCacheHandler
if (globalCacheHandler) {
CurCacheHandler = globalCacheHandler
}
if (!CurCacheHandler) {
if (fs && serverDistDir) {
if (debug) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment