@@ -55,23 +55,23 @@ export default class Cache {
5555 const softTags = typeof options === "object" ? options . softTags : [ ] ;
5656 const tags = typeof options === "object" ? options . tags : [ ] ;
5757 const isDataCache = isFetchCache ( options ) ;
58- const key = createCacheKey ( baseKey , isDataCache ) ;
5958 return isDataCache
60- ? this . getFetchCache ( key , softTags , tags )
61- : this . getIncrementalCache ( key ) ;
59+ ? this . getFetchCache ( baseKey , softTags , tags )
60+ : this . getIncrementalCache ( baseKey ) ;
6261 }
6362
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 } ) ;
6665 try {
66+ const key = createCacheKey ( baseKey , true ) ;
6767 const cachedEntry = await globalThis . incrementalCache . get ( key , "fetch" ) ;
6868
6969 if ( cachedEntry ?. value === undefined ) return null ;
7070
7171 const _tags = [ ...( tags ?? [ ] ) , ...( softTags ?? [ ] ) ] ;
7272 const _lastModified = cachedEntry . lastModified ?? Date . now ( ) ;
7373 const _hasBeenRevalidated = await hasBeenRevalidated (
74- key ,
74+ baseKey ,
7575 _tags ,
7676 cachedEntry ,
7777 ) ;
@@ -112,8 +112,11 @@ export default class Cache {
112112 }
113113 }
114114
115- async getIncrementalCache ( key : string ) : Promise < CacheHandlerValue | null > {
115+ async getIncrementalCache (
116+ baseKey : string ,
117+ ) : Promise < CacheHandlerValue | null > {
116118 try {
119+ const key = createCacheKey ( baseKey , false ) ;
117120 const cachedEntry = await globalThis . incrementalCache . get ( key , "cache" ) ;
118121
119122 if ( ! cachedEntry ?. value ) {
@@ -126,7 +129,7 @@ export default class Cache {
126129 const tags = getTagsFromValue ( cacheData ) ;
127130 const _lastModified = cachedEntry . lastModified ?? Date . now ( ) ;
128131 const _hasBeenRevalidated = await hasBeenRevalidated (
129- key ,
132+ baseKey ,
130133 tags ,
131134 cachedEntry ,
132135 ) ;
@@ -311,7 +314,7 @@ export default class Cache {
311314 }
312315 }
313316
314- await this . updateTagsOnSet ( key , data , ctx ) ;
317+ await this . updateTagsOnSet ( baseKey , data , ctx ) ;
315318 debug ( "Finished setting cache" ) ;
316319 } catch ( e ) {
317320 error ( "Failed to set cache" , e ) ;
0 commit comments