Can the revalidate time on unstable_cache be dynamic, based on the data it is cached?
Unanswered
Champagne D’Argent posted this in #help-forum
Champagne D’ArgentOP
I basically want to achieve this:
and have the revalidate time not be 1 day, but rather
const getCachedCurrentYear = unstable_cache(
async function getCurrentYear() {
const thisYearsMeeting = await database.getCurrentYear();
if (!thisYearsMeeting) {
redirect("/inactive");
}
const cacheTimeInSeconds = calculateRevalidationTime(thisYearsMeeting);
// Can I set cache to cacheTimeInSeconds?
return thisYearsMeeting;
},
[],
{
revalidate: 3600 * 24, // 1 day
tags: ["current-year"],
}
);
and have the revalidate time not be 1 day, but rather
cacheTimeInSeconds
. Is this doable?1 Reply
Champagne D’ArgentOP
bump!