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
feat(next/app-dir): contextCache
to control context values to add to cacheTag
#5458
Conversation
This change allows a user to specify `contextCache` method in the `experimental_nextCacheLink`, which lets one select the values from the context that should be considered when a `cacheTag` is generated. It also changes the way `cacheTag` is generated, taking care of the fact that the `cacheTag` cannot be longer then 256 characters, thus instead of stringifying input values, it will form a sha-256 hash of those. Implements trpc#5455
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
@dalechyn is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
@KATT, I need some help figuring this part out. Anyway, the commit should not break those as the |
@juliusmarminge, ci fails as webpack cannot import also found this thing: https://nextjs.org/docs/messages/node-module-in-edge-runtime, that might indicate that it would not be possible to use UPD: it is supported, https://nextjs.org/docs/pages/api-reference/edge#crypto-apis |
* define which values from the context should be considered into the cache | ||
* key | ||
*/ | ||
cacheContext?: (ctx: inferRouterContext<TRouter>) => any[]; |
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.
while we don't have docs for these stuff yet, maybe include this in the example we have that's using this link so that people can know about it somehow.
i'd almost be inclined to make it required even since it's a vital part of getting the right cache key and making sure different users doesn't share the same cache entries?
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 suggest making this property | undefined
instead of partial so that user is explicitly passing undefined
if he doesn't want to manipulate the cache key.
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.
included in the example, and made the property | undefined
.
@juliusmarminge i need some guidance here, i'm not sure wether I'm on the right or wrong direction. Starting to have a real type battle here. |
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Closes: #5455
π― Changes
This change allows a user to specify
contextCache
method in theexperimental_nextCacheLink
, which lets one select the values from the context that should be considered when acacheTag
is generated.It also changes the way
cacheTag
is generated, taking care of the fact that thecacheTag
cannot be longer then 256 characters, thus instead of stringifying input values, it will form a sha-256 hash of those.β Checklist