diff --git a/packages/next/src/server/lib/incremental-cache/fetch-cache.ts b/packages/next/src/server/lib/incremental-cache/fetch-cache.ts index 896795ec08737..e0361c5c23075 100644 --- a/packages/next/src/server/lib/incremental-cache/fetch-cache.ts +++ b/packages/next/src/server/lib/incremental-cache/fetch-cache.ts @@ -142,19 +142,13 @@ export default class FetchCache implements CacheHandler { } } - public async get( - key: string, - ctx: { - tags?: string[] - softTags?: string[] - fetchCache?: boolean - fetchUrl?: string - fetchIdx?: number - } - ) { - const { tags, softTags, fetchCache, fetchIdx, fetchUrl } = ctx + public async get(...args: Parameters) { + const [key, ctx = {}] = args + const { tags, softTags, kindHint, fetchIdx, fetchUrl } = ctx - if (!fetchCache) return null + if (kindHint !== 'fetch') { + return null + } if (Date.now() < rateLimitedUntil) { if (this.debug) { @@ -262,21 +256,9 @@ export default class FetchCache implements CacheHandler { return data || null } - public async set( - key: string, - data: CacheHandlerValue['value'], - { - fetchCache, - fetchIdx, - fetchUrl, - tags, - }: { - tags?: string[] - fetchCache?: boolean - fetchUrl?: string - fetchIdx?: number - } - ) { + public async set(...args: Parameters) { + const [key, data, ctx] = args + const { fetchCache, fetchIdx, fetchUrl, tags } = ctx if (!fetchCache) return if (Date.now() < rateLimitedUntil) { diff --git a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts index 75cbc06b9ef35..a742279ea2c00 100644 --- a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts +++ b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts @@ -1,10 +1,7 @@ import type { RouteMetadata } from '../../../export/routes/types' import type { CacheHandler, CacheHandlerContext, CacheHandlerValue } from './' import type { CacheFs } from '../../../shared/lib/utils' -import type { - CachedFetchValue, - IncrementalCacheKindHint, -} from '../../response-cache' +import type { CachedFetchValue } from '../../response-cache' import LRUCache from 'next/dist/compiled/lru-cache' import path from '../../../shared/lib/isomorphic/path' @@ -120,18 +117,9 @@ export default class FileSystemCache implements CacheHandler { } } - public async get( - key: string, - { - tags, - softTags, - kindHint, - }: { - tags?: string[] - softTags?: string[] - kindHint?: IncrementalCacheKindHint - } = {} - ) { + public async get(...args: Parameters) { + const [key, ctx = {}] = args + const { tags, softTags, kindHint } = ctx let data = memoryCache?.get(key) // let's check the disk for seed data @@ -302,13 +290,8 @@ export default class FileSystemCache implements CacheHandler { return data ?? null } - public async set( - key: string, - data: CacheHandlerValue['value'], - ctx: { - tags?: string[] - } - ) { + public async set(...args: Parameters) { + const [key, data, ctx] = args memoryCache?.set(key, { value: data, lastModified: Date.now(),