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