Skip to content
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

[Feature] Add another mode for the tag cache #706

Open
conico974 opened this issue Jan 21, 2025 · 0 comments
Open

[Feature] Add another mode for the tag cache #706

conico974 opened this issue Jan 21, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@conico974
Copy link
Contributor

Right now the tag cache is made to work mostly with DynamoDB and does not work in the same way as in next standalone. We should add a different mode for the tag cache (and support both) that would work in the same way as in next standalone.

We should probably add a dynamodb-nextmode override and add some docs explaining the difference and which one you should choose


Current Implementation

On get

We just check for the cache key in the tag cache without having to reach the incremental cache. If it has been revalidated we just return null, otherwise we continue and check the incremental cache

On set

We have to write both the incremental cache and check the tag cache for non existing tag/key combination. For non existing tag/key combination, we have to add them

On revalidateTag for each tag

We have to update every possible combination for the requested tag

Pros

  • Very fast on read
  • Only one query per get (On DynamoDB it's a lot cheaper)
  • Avoid having to reach the incremental cache for revalidated item

Cons

  • Lots of write on set and revalidateTag
  • Needs to be prepopulated at build time to work properly

New Mode

On get

We have to check for every tag (after reading the incremental cache) that they have not been revalidated.

In DynamoDB, this would require 1 GetItem per tag (including internal one), more realistically 1 BatchGetItem per get (In terms of pricing, it would be billed as multiple single GetItem)

On set

We don't have to do anything here

On revalidateTag for each tag

We have to update a single entry for this tag

Pros

  • No need to prepopulate DDB
  • Very little write

Cons

  • Might be slower on read
  • One page request (i.e. GET request) could require to check a lot of tags (And some of them multiple time when used with the fetch cache)
  • Needs to reach the incremental cache first on get
@conico974 conico974 added the enhancement New feature or request label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant