@@ -54,23 +54,23 @@ export default class Cache {
54
54
const softTags = typeof options === "object" ? options . softTags : [ ] ;
55
55
const tags = typeof options === "object" ? options . tags : [ ] ;
56
56
const isDataCache = isFetchCache ( options ) ;
57
- const key = createCacheKey ( baseKey , isDataCache ) ;
58
57
return isDataCache
59
- ? this . getFetchCache ( key , softTags , tags )
60
- : this . getIncrementalCache ( key ) ;
58
+ ? this . getFetchCache ( baseKey , softTags , tags )
59
+ : this . getIncrementalCache ( baseKey ) ;
61
60
}
62
61
63
- async getFetchCache ( key : string , softTags ?: string [ ] , tags ?: string [ ] ) {
64
- debug ( "get fetch cache" , { key , softTags, tags } ) ;
62
+ async getFetchCache ( baseKey : string , softTags ?: string [ ] , tags ?: string [ ] ) {
63
+ debug ( "get fetch cache" , { baseKey , softTags, tags } ) ;
65
64
try {
65
+ const key = createCacheKey ( baseKey , true ) ;
66
66
const cachedEntry = await globalThis . incrementalCache . get ( key , "fetch" ) ;
67
67
68
68
if ( cachedEntry ?. value === undefined ) return null ;
69
69
70
70
const _tags = [ ...( tags ?? [ ] ) , ...( softTags ?? [ ] ) ] ;
71
71
const _lastModified = cachedEntry . lastModified ?? Date . now ( ) ;
72
72
const _hasBeenRevalidated = await hasBeenRevalidated (
73
- key ,
73
+ baseKey ,
74
74
_tags ,
75
75
cachedEntry ,
76
76
) ;
@@ -111,8 +111,11 @@ export default class Cache {
111
111
}
112
112
}
113
113
114
- async getIncrementalCache ( key : string ) : Promise < CacheHandlerValue | null > {
114
+ async getIncrementalCache (
115
+ baseKey : string ,
116
+ ) : Promise < CacheHandlerValue | null > {
115
117
try {
118
+ const key = createCacheKey ( baseKey , false ) ;
116
119
const cachedEntry = await globalThis . incrementalCache . get ( key , "cache" ) ;
117
120
118
121
if ( ! cachedEntry ?. value ) {
@@ -125,7 +128,7 @@ export default class Cache {
125
128
const tags = getTagsFromValue ( cacheData ) ;
126
129
const _lastModified = cachedEntry . lastModified ?? Date . now ( ) ;
127
130
const _hasBeenRevalidated = await hasBeenRevalidated (
128
- key ,
131
+ baseKey ,
129
132
tags ,
130
133
cachedEntry ,
131
134
) ;
@@ -310,7 +313,7 @@ export default class Cache {
310
313
}
311
314
}
312
315
313
- await this . updateTagsOnSet ( key , data , ctx ) ;
316
+ await this . updateTagsOnSet ( baseKey , data , ctx ) ;
314
317
debug ( "Finished setting cache" ) ;
315
318
} catch ( e ) {
316
319
error ( "Failed to set cache" , e ) ;
0 commit comments