@@ -30,22 +30,18 @@ import {
30
30
import { getLogger , getRequestContext } from './request-context.cjs'
31
31
import { getTracer , recordWarning } from './tracer.cjs'
32
32
33
- type TagManifestBlobCache = Record < string , Promise < TagManifest | null > >
34
-
35
33
const purgeCacheUserAgent = `${ nextRuntimePkgName } @${ nextRuntimePkgVersion } `
36
34
37
35
export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
38
36
options : CacheHandlerContext
39
37
revalidatedTags : string [ ]
40
38
cacheStore : MemoizedKeyValueStoreBackedByRegionalBlobStore
41
39
tracer = getTracer ( )
42
- tagManifestsFetchedFromBlobStoreInCurrentRequest : TagManifestBlobCache
43
40
44
41
constructor ( options : CacheHandlerContext ) {
45
42
this . options = options
46
43
this . revalidatedTags = options . revalidatedTags
47
44
this . cacheStore = getMemoizedKeyValueStoreBackedByRegionalBlobStore ( { consistency : 'strong' } )
48
- this . tagManifestsFetchedFromBlobStoreInCurrentRequest = { }
49
45
}
50
46
51
47
private getTTL ( blob : NetlifyCacheHandlerValue ) {
@@ -469,7 +465,8 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
469
465
}
470
466
471
467
resetRequestCache ( ) {
472
- this . tagManifestsFetchedFromBlobStoreInCurrentRequest = { }
468
+ // no-op because in-memory cache is scoped to requests and not global
469
+ // see getRequestSpecificInMemoryCache
473
470
}
474
471
475
472
/**
@@ -508,10 +505,9 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
508
505
}
509
506
510
507
// 2. If any in-memory tags don't indicate that any of tags was invalidated
511
- // we will check blob store, but memoize results for duration of current request
512
- // so that we only check blob store once per tag within a single request
513
- // full-route cache and fetch caches share a lot of tags so this might save
514
- // some roundtrips to the blob store.
508
+ // we will check blob store. Full-route cache and fetch caches share a lot of tags
509
+ // but we will only do actual blob read once withing a single request due to cacheStore
510
+ // memoization.
515
511
// Additionally, we will resolve the promise as soon as we find first
516
512
// stale tag, so that we don't wait for all of them to resolve (but keep all
517
513
// running in case future `CacheHandler.get` calls would be able to use results).
@@ -521,14 +517,10 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
521
517
const tagManifestPromises : Promise < boolean > [ ] = [ ]
522
518
523
519
for ( const tag of cacheTags ) {
524
- let tagManifestPromise : Promise < TagManifest | null > =
525
- this . tagManifestsFetchedFromBlobStoreInCurrentRequest [ tag ]
526
-
527
- if ( ! tagManifestPromise ) {
528
- tagManifestPromise = this . cacheStore . get < TagManifest > ( tag , 'tagManifest.get' )
529
-
530
- this . tagManifestsFetchedFromBlobStoreInCurrentRequest [ tag ] = tagManifestPromise
531
- }
520
+ const tagManifestPromise : Promise < TagManifest | null > = this . cacheStore . get < TagManifest > (
521
+ tag ,
522
+ 'tagManifest.get' ,
523
+ )
532
524
533
525
tagManifestPromises . push (
534
526
tagManifestPromise . then ( ( tagManifest ) => {
0 commit comments