Next.js Discord

Discord Forum

unstable

Unanswered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
Hi guys, I would love to use the unstable cache, has anyone used it yet or any tips . Thanks

17 Replies

i have used it... its pretty cool
the only tips is you may need to wrap it inside react cache if you want it to dedupe (ie run function twice in render of page... dedup would make it only do once)
Giant pandaOP
Nice. Can I share what I plan to wrap inside the cache itself
sure
for context this is how i have made use of it (you dont neex to do the same degree tho https://github.com/RiskyMH/Email/blob/5e869dd732b93a214baf15c8d42620b680ffd3e9/app/(email)/mail/%5Bmailbox%5D/tools.ts#L8-L36
Giant pandaOP
Ok thanks, will check ✔️ it out
Basset Fauve de Bretagne
@riský Nice tip! However as unstable cache is actually getting cached data, it should be ok, the difference is that the cache is in another layer right?
Basset Fauve de Bretagne
@riský I’m just saying that unstable cache will return cached values even if called twice right? react cache will just in fact wrap another cache layer.
it returnes cached value
however if you run the function at same time it will do your db query or function twice
which is why you need react cache to dedup it
Basset Fauve de Bretagne
Yep i see, Nextjs team should actually include this dedup in their cache function 🙏
Yeah it is really missing and does I feed confuse so many (me included)
Basset Fauve de Bretagne
Thanks @riský will check it out 🙌