@@ -6,6 +6,7 @@ import type {
66import  type  {  CacheKey  }  from  "types/overrides" ; 
77import  { 
88  createCacheKey , 
9+   createTagKey , 
910  getTagsFromValue , 
1011  hasBeenRevalidated , 
1112  writeTags , 
@@ -71,7 +72,7 @@ export default class Cache {
7172      const  _tags  =  [ ...( tags  ??  [ ] ) ,  ...( softTags  ??  [ ] ) ] ; 
7273      const  _lastModified  =  cachedEntry . lastModified  ??  Date . now ( ) ; 
7374      const  _hasBeenRevalidated  =  await  hasBeenRevalidated ( 
74-         baseKey , 
75+         key , 
7576        _tags , 
7677        cachedEntry , 
7778      ) ; 
@@ -90,7 +91,7 @@ export default class Cache {
9091        ) ; 
9192        if  ( path )  { 
9293          const  hasPathBeenUpdated  =  await  hasBeenRevalidated ( 
93-             path . replace ( "_N_T_/" ,  "" ) , 
94+             createCacheKey ( { key :  path . replace ( "_N_T_/" ,  "" ) ,   type :  "cache" } ) , 
9495            [ ] , 
9596            cachedEntry , 
9697          ) ; 
@@ -132,7 +133,7 @@ export default class Cache {
132133      const  tags  =  getTagsFromValue ( cacheData ) ; 
133134      const  _lastModified  =  cachedEntry . lastModified  ??  Date . now ( ) ; 
134135      const  _hasBeenRevalidated  =  await  hasBeenRevalidated ( 
135-         baseKey , 
136+         key , 
136137        tags , 
137138        cachedEntry , 
138139      ) ; 
@@ -323,7 +324,7 @@ export default class Cache {
323324
324325    try  { 
325326      if  ( globalThis . tagCache . mode  ===  "nextMode" )  { 
326-         const  paths  =  ( await  globalThis . tagCache . getPathsByTags ?.( _tags ) )  ??  [ ] ; 
327+         const  paths  =  ( await  globalThis . tagCache . getPathsByTags ?.( _tags . map ( createTagKey ) ) )  ??  [ ] ; 
327328
328329        await  writeTags ( _tags ) ; 
329330        if  ( paths . length  >  0 )  { 
@@ -349,7 +350,7 @@ export default class Cache {
349350      for  ( const  tag  of  _tags )  { 
350351        debug ( "revalidateTag" ,  tag ) ; 
351352        // Find all keys with the given tag 
352-         const  paths  =  await  globalThis . tagCache . getByTag ( tag ) ; 
353+         const  paths  =  await  globalThis . tagCache . getByTag ( createTagKey ( tag ) ) ; 
353354        debug ( "Items" ,  paths ) ; 
354355        const  toInsert  =  paths . map ( ( path )  =>  ( { 
355356          path, 
@@ -360,11 +361,11 @@ export default class Cache {
360361        if  ( tag . startsWith ( "_N_T_/" ) )  { 
361362          for  ( const  path  of  paths )  { 
362363            // We need to find all hard tags for a given path 
363-             const  _tags  =  await  globalThis . tagCache . getByPath ( path ) ; 
364+             const  _tags  =  await  globalThis . tagCache . getByPath ( createTagKey ( path ) ) ; 
364365            const  hardTags  =  _tags . filter ( ( t )  =>  ! t . startsWith ( "_N_T_/" ) ) ; 
365366            // For every hard tag, we need to find all paths and revalidate them 
366367            for  ( const  hardTag  of  hardTags )  { 
367-               const  _paths  =  await  globalThis . tagCache . getByTag ( hardTag ) ; 
368+               const  _paths  =  await  globalThis . tagCache . getByTag ( createTagKey ( hardTag ) ) ; 
368369              debug ( {  hardTag,  _paths } ) ; 
369370              toInsert . push ( 
370371                ..._paths . map ( ( path )  =>  ( { 
@@ -377,7 +378,10 @@ export default class Cache {
377378        } 
378379
379380        // Update all keys with the given tag with revalidatedAt set to now 
380-         await  writeTags ( toInsert ) ; 
381+         await  writeTags ( toInsert . map ( ( t )  =>  ( { 
382+           path : createTagKey ( t . path ) , 
383+           tag : createTagKey ( t . tag ) , 
384+         } ) ) ) ; 
381385
382386        // We can now invalidate all paths in the CDN 
383387        // This only applies to `revalidateTag`, not to `res.revalidate()` 
@@ -438,13 +442,13 @@ export default class Cache {
438442
439443    // Get all tags stored in dynamodb for the given key 
440444    // If any of the derived tags are not stored in dynamodb for the given key, write them 
441-     const  storedTags  =  await  globalThis . tagCache . getByPath ( key ) ; 
445+     const  storedTags  =  await  globalThis . tagCache . getByPath ( createTagKey ( key ) ) ; 
442446    const  tagsToWrite  =  derivedTags . filter ( ( tag )  =>  ! storedTags . includes ( tag ) ) ; 
443447    if  ( tagsToWrite . length  >  0 )  { 
444448      await  writeTags ( 
445449        tagsToWrite . map ( ( tag )  =>  ( { 
446-           path : key , 
447-           tag : tag , 
450+           path : createTagKey ( key ) , 
451+           tag : createTagKey ( tag ) , 
448452          // In case the tags are not there we just need to create them 
449453          // but we don't want them to return from `getLastModified` as they are not stale 
450454          revalidatedAt : 1 , 
0 commit comments