-
Notifications
You must be signed in to change notification settings - Fork 170
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
Conversation
🦋 Changeset detectedLatest commit: e0bc614 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Thanks for the review Kheuzy! |
export default { | ||
name: "fs-dev-nextMode", | ||
mode: "nextMode", | ||
getLastRevalidated: async (tagsToCheck: string[]) => { |
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.
I'm not familiar w/ the base spec for tag cache. I see writeTags
, shouldn't there be a readTags
?
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.
This is for the new tagCache
mode called nextMode
. It works a bit different, and also is necessary to make composable cache work when that becomes stable.
hasBeenRevalidated()
will check if any tags have been revalidated. You can see it in action here:
opennextjs-aws/packages/open-next/src/utils/cache.ts
Lines 25 to 27 in 31c3740
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
export default { | ||
name: "fs-dev-nextMode", | ||
mode: "nextMode", | ||
getLastRevalidated: async (tagsToCheck: string[]) => { |
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
Thanks Nico! Was a much better idea to use a Map. This |
This is for #958. Our goal is to make E2E work locally
With this new override
revalidateTag
andrevalidatePath
will work out of the box running OpenNext locally. This override can be used to support composable caching when that becomes stable aswell. There will come more PRs to make E2E work locally.