Will unstable_cache
be stabilized alongside use cache
?
#71835
Unanswered
sannajammeh
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
use cache
is an excellent addition to the Next.js codebase, however it does not fit in with libraries as its so tightly coupled to the Next.js codebase.We have several libraries in the works for CMS's which are able to be provided a cacheFunction when initialized. This makes the library fully able to run both in Next.js and in other frameworks. We then leverage the heuristics of
unstable_cache
in our project code to enable a full cache on the library.Take the following user code example:
src/lib/animal-api.ts
src/app/page.tsx
Afaik this behaviour which works excellent for us in our current libraries is not possible with the new "use cache" API.
I've made an initial attempt which does not work:
This results in the following error:
I sincerely hope you either A. allow an outer scope to provide a function into a "use cache" function, or B keep unstable_cache around and stabilize it alongside "use cache" options.
For option A, I don't really see an issue allowing the outer scoped
callback
to be accessible inside the inner function as it will only be called during a cache miss/stale, meaning thecallback
function is already fresh.Beta Was this translation helpful? Give feedback.
All reactions