File tree 3 files changed +314
-57
lines changed
3 files changed +314
-57
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import { setupWaitUntil } from './wait-until.cjs'
25
25
setFetchBeforeNextPatchedIt ( globalThis . fetch )
26
26
// configure some globals that Next.js make use of before we start importing any Next.js code
27
27
// as some globals are consumed at import time
28
+ // TODO: only call this if Next.js version is using CacheHandlerV2 as we don't have V1 compatible implementation
28
29
configureUseCacheHandlers ( )
29
30
setupWaitUntil ( )
30
31
Original file line number Diff line number Diff line change @@ -25,6 +25,27 @@ async function lastTagRevalidationTimestamp(
25
25
return tagManifest . revalidatedAt
26
26
}
27
27
28
+ /**
29
+ * Get the most recent revalidation timestamp for a list of tags
30
+ */
31
+ export async function getMostRecentTagRevalidationTimestamp ( tags : string [ ] ) {
32
+ if ( tags . length === 0 ) {
33
+ return 0
34
+ }
35
+
36
+ const cacheStore = getMemoizedKeyValueStoreBackedByRegionalBlobStore ( { consistency : 'strong' } )
37
+
38
+ const timestampsOrNulls = await Promise . all (
39
+ tags . map ( ( tag ) => lastTagRevalidationTimestamp ( tag , cacheStore ) ) ,
40
+ )
41
+
42
+ const timestamps = timestampsOrNulls . filter ( ( timestamp ) => timestamp !== null )
43
+ if ( timestamps . length === 0 ) {
44
+ return 0
45
+ }
46
+ return Math . max ( ...timestamps )
47
+ }
48
+
28
49
/**
29
50
* Check if any of the tags were invalidated since the given timestamp
30
51
*/
You can’t perform that action at this time.
0 commit comments