-
Notifications
You must be signed in to change notification settings - Fork 176
add(dev-overrides): In memory tagCache with nextMode #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
ae798bf
e8d1e24
371fdf8
bb2363f
8e3d270
71603ae
c7e4796
e0bc614
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@opennextjs/aws": patch | ||
--- | ||
|
||
add(dev-overrides): In memory tagCache with nextMode |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,90 @@ | ||||||||
import fs from "node:fs"; | ||||||||
import path from "node:path"; | ||||||||
|
||||||||
import type { NextModeTagCache } from "types/overrides"; | ||||||||
import { getMonorepoRelativePath } from "utils/normalize-path"; | ||||||||
import { debug } from "../../adapters/logger"; | ||||||||
|
||||||||
const tagFile = path.join( | ||||||||
getMonorepoRelativePath(), | ||||||||
"dynamodb-provider/dynamodb-cache.json", | ||||||||
); | ||||||||
const tagContent = fs.readFileSync(tagFile, "utf-8"); | ||||||||
|
||||||||
let tags = JSON.parse(tagContent) as { | ||||||||
tag: { S: string }; | ||||||||
sommeeeer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
path: { S: string }; | ||||||||
revalidatedAt: { N: string }; | ||||||||
}[]; | ||||||||
|
||||||||
function buildKey(key: string) { | ||||||||
const { NEXT_BUILD_ID } = process.env; | ||||||||
return path.posix.join(NEXT_BUILD_ID ?? "", key); | ||||||||
sommeeeer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
} | ||||||||
|
||||||||
function buildObject(tag: string, revalidatedAt?: number) { | ||||||||
return { | ||||||||
path: { S: buildKey(tag) }, | ||||||||
tag: { S: buildKey(tag) }, | ||||||||
revalidatedAt: { N: `${revalidatedAt ?? Date.now()}` }, | ||||||||
}; | ||||||||
} | ||||||||
|
||||||||
export default { | ||||||||
name: "fs-dev-nextMode", | ||||||||
mode: "nextMode", | ||||||||
getLastRevalidated: async (tagsToCheck: string[]) => { | ||||||||
|
if (globalThis.tagCache.mode === "nextMode") { | |
return await globalThis.tagCache.hasBeenRevalidated(tags, lastModified); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which part of the code reads and load the tags that was written to the file system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/opennextjs/opennextjs-aws/blob/31c3740/packages/open-next/src/build/createAssets.ts#L253-L269 - the dynamodb-cache.json
gets written here during build. In our fs-dev-nextMode
override we read that file on top level and put it in a let tags = ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Composable cache works with the original tag cache as well. And you don't need the original file
Uh oh!
There was an error while loading. Please reload this page.