@@ -54,23 +54,23 @@ export default class Cache {
5454 const softTags = typeof options === "object" ? options . softTags : [ ] ;
5555 const tags = typeof options === "object" ? options . tags : [ ] ;
5656 const isDataCache = isFetchCache ( options ) ;
57- const key = createCacheKey ( baseKey , isDataCache ) ;
5857 return isDataCache
59- ? this . getFetchCache ( key , softTags , tags )
60- : this . getIncrementalCache ( key ) ;
58+ ? this . getFetchCache ( baseKey , softTags , tags )
59+ : this . getIncrementalCache ( baseKey ) ;
6160 }
6261
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 } ) ;
6564 try {
65+ const key = createCacheKey ( baseKey , true ) ;
6666 const cachedEntry = await globalThis . incrementalCache . get ( key , "fetch" ) ;
6767
6868 if ( cachedEntry ?. value === undefined ) return null ;
6969
7070 const _tags = [ ...( tags ?? [ ] ) , ...( softTags ?? [ ] ) ] ;
7171 const _lastModified = cachedEntry . lastModified ?? Date . now ( ) ;
7272 const _hasBeenRevalidated = await hasBeenRevalidated (
73- key ,
73+ baseKey ,
7474 _tags ,
7575 cachedEntry ,
7676 ) ;
@@ -111,8 +111,11 @@ export default class Cache {
111111 }
112112 }
113113
114- async getIncrementalCache ( key : string ) : Promise < CacheHandlerValue | null > {
114+ async getIncrementalCache (
115+ baseKey : string ,
116+ ) : Promise < CacheHandlerValue | null > {
115117 try {
118+ const key = createCacheKey ( baseKey , false ) ;
116119 const cachedEntry = await globalThis . incrementalCache . get ( key , "cache" ) ;
117120
118121 if ( ! cachedEntry ?. value ) {
@@ -125,7 +128,7 @@ export default class Cache {
125128 const tags = getTagsFromValue ( cacheData ) ;
126129 const _lastModified = cachedEntry . lastModified ?? Date . now ( ) ;
127130 const _hasBeenRevalidated = await hasBeenRevalidated (
128- key ,
131+ baseKey ,
129132 tags ,
130133 cachedEntry ,
131134 ) ;
@@ -310,7 +313,7 @@ export default class Cache {
310313 }
311314 }
312315
313- await this . updateTagsOnSet ( key , data , ctx ) ;
316+ await this . updateTagsOnSet ( baseKey , data , ctx ) ;
314317 debug ( "Finished setting cache" ) ;
315318 } catch ( e ) {
316319 error ( "Failed to set cache" , e ) ;
0 commit comments