Skip to content

Feat tag-cache-filter #608

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

Merged
merged 3 commits into from
Apr 28, 2025
Merged

Conversation

conico974
Copy link
Collaborator

Add a new withFilter "tag cache" that allows to filter the tag used.
It is mostly useful to reduce the load on the underlying tag cache.
It also introduce a softTagFilter function for those that uses revalidateTag, but not revalidatePath

Copy link

changeset-bot bot commented Apr 28, 2025

🦋 Changeset detected

Latest commit: 58af07b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

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

Copy link

pkg-pr-new bot commented Apr 28, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@608

commit: 58af07b

"@opennextjs/cloudflare": patch
---

Add a new `withFilter` tag cache to allow to filter the tag cache used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add a new `withFilter` tag cache to allow to filter the tag cache used
Add a new `withFilter` tag cache to allow to filter the tags used

expect(tagCache.getPathsByTags).toBeUndefined();
});

it("should properly filter soft tags", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it("should properly filter soft tags", () => {
it("should filter soft tags", () => {

Comment on lines 4 to 8
/**
* The original tag cache.
* Call to this will receive only the filtered tags.
*/
originalTagCache: NextModeTagCache;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe?

Suggested change
/**
* The original tag cache.
* Call to this will receive only the filtered tags.
*/
originalTagCache: NextModeTagCache;
/**
* The wrapped tag cache.
* Call to this will receive only the filtered tags.
*/
tagCache: NextModeTagCache;

/**
* The function to filter tags.
* @param tag The tag to filter.
* @returns true if the tag should be forwarde, false otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns true if the tag should be forwarde, false otherwise.
* @returns true if the tag should be forwarded, false otherwise.


/**
* Creates a new tag cache that filters tags based on the provided filter function.
* This is usefult to remove tags that are not used by the app, this could reduce the number of request to the underlying tag cache.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This is usefult to remove tags that are not used by the app, this could reduce the number of request to the underlying tag cache.
* This is usefull to remove tags that are not used by the app, this could reduce the number of requests to the underlying tag cache.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a few minor comments

@conico974 conico974 merged commit 055a61b into opennextjs:main Apr 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants