@@ -16,24 +16,20 @@ import {
16
16
} from './tags-handler.cjs'
17
17
import { getTracer } from './tracer.cjs'
18
18
19
- // copied from default implementation
20
- // packages/next/src/server/lib/cache-handlers/default.ts
19
+ // Most of this code is copied and adapted from Next.js default 'use cache' handler implementation
20
+ // https://github.com/vercel/next.js/blob/84fde91e03918344c5d356986914ab68a5083462/packages/next/src/server/lib/cache-handlers/default.ts
21
+ // this includes:
22
+ // - PrivateCacheEntry (with removed `isErrored` and `errorRetryCount` as those are not actually used there)
23
+ // - Main logic of .get and .set methods
24
+ // Main difference is:
25
+ // - Tag handling - default Next.js implementation handles tags in memory only, but we need to support tag
26
+ // invalidation cross serverless instances, so we do use same persistent storage as we use for response and fetch cache
27
+ // Additionally we do not actually implement refreshTags to update in-memory tag manifest as this operation is blocking
28
+ // and our serverless instances also can handle any page template so implementing it would not have good perf tradeoffs
29
+ // - Addition of tracing
30
+
21
31
type PrivateCacheEntry = {
22
32
entry : CacheEntry
23
-
24
- // For the default cache we store errored cache
25
- // entries and allow them to be used up to 3 times
26
- // after that we want to dispose it and try for fresh
27
-
28
- // If an entry is errored we return no entry
29
- // three times so that we retry hitting origin (MISS)
30
- // and then if it still fails to set after the third we
31
- // return the errored content and use expiration of
32
- // Math.min(30, entry.expiration)
33
-
34
- isErrored : boolean // pieh: this doesn't seem to be actually used in the default implementation
35
- errorRetryCount : number // pieh: this doesn't seem to be actually used in the default implementation
36
-
37
33
// compute size on set since we need to read size
38
34
// of the ReadableStream for LRU evicting
39
35
size : number
@@ -207,8 +203,6 @@ export const NetlifyDefaultUseCacheHandler = {
207
203
208
204
getLRUCache ( ) . set ( cacheKey , {
209
205
entry,
210
- isErrored : false ,
211
- errorRetryCount : 0 ,
212
206
size,
213
207
} )
214
208
} catch ( error ) {
0 commit comments