Next.js Discord

Discord Forum

Vercel KV doesn't work with `unsable_cache`

Unanswered
Asian paper wasp posted this in #help-forum
Open in Discord
Asian paper waspOP
When every I wrap @vercel/kv instead unstable_cache, e.g.

const metadata = await unstable_cache(
  () => kv.hgetall<{ like: number }>(`blog:metadata:${blog.id}`),
  [blog.id],
  { tags: [`blog:metadata:${blog.id}`] },
)();


I will get an error of

 X Error: cache: 'force-cache' used on fetch for <vercel_kv_domain> with 'export const fetchCache = 'only-no-store'


I've tried with other data fetching libraries, e.g. contentful which is making use of Axios internally, and doesn't have any issue there.

What could be the issues?

6 Replies

vercel kv seems to force no cache, and thus unstable_cache doesn't work well? - but also its unstable for a reason
Asian paper waspOP
It does? That means I can simply call revalidatePath after I hset some stuff and the (partically) static page will be auto updated with the new content?
'only-no-store': Ensure all fetch requests opt out of caching by changing the default to cache: 'no-store' if no option is provided and causing an error if any fetch requests use cache: 'force-cache'
i think unstable_cache may be setting force-cache here... but are you setting it anywhere?
i think the point of vercel kv is to have so high speed that caching is unnecessary - and i vercal cache uses a key value database anyway
Asian paper waspOP
Let me give it a try