mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
8cab15c0c9
`cacheLife` is now stable and does not require an unstable prefix
34 lines
887 B
TypeScript
34 lines
887 B
TypeScript
import { cacheLife } from 'next/cache'
|
|
import { setTimeout } from 'timers/promises'
|
|
|
|
export async function uncachedIO() {
|
|
await setTimeout(0)
|
|
}
|
|
|
|
export async function cachedDelay(key: any) {
|
|
'use cache'
|
|
cacheLife('minutes')
|
|
await setTimeout(1)
|
|
}
|
|
|
|
export function DebugRenderKind() {
|
|
const { workUnitAsyncStorage } =
|
|
require('next/dist/server/app-render/work-unit-async-storage.external') as typeof import('next/dist/server/app-render/work-unit-async-storage.external')
|
|
const workUnitStore = workUnitAsyncStorage.getStore()!
|
|
return (
|
|
<div>
|
|
workUnitStore.type: {workUnitStore.type}
|
|
{(() => {
|
|
switch (workUnitStore.type) {
|
|
case 'prerender':
|
|
return '(static prefetch)'
|
|
case 'prerender-runtime':
|
|
return '(runtime prefetch)'
|
|
default:
|
|
return null
|
|
}
|
|
})()}
|
|
</div>
|
|
)
|
|
}
|