Skip to content

Instantly share code, notes, and snippets.

@pontusab
Created January 31, 2024 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pontusab/da73137336cac20a4bce3ded5237af29 to your computer and use it in GitHub Desktop.
Save pontusab/da73137336cac20a4bce3ded5237af29 to your computer and use it in GitHub Desktop.
cached-queries.ts
export const getMetrics = async (params) => {
const supabase = createClient();
const user = await getUser();
const teamId = user?.data?.team_id;
if (!teamId) {
return null;
}
return unstable_cache(
async () => {
return getMetricsQuery(supabase, { ...params, teamId });
},
["metrics", teamId],
{
tags: [`metrics_${teamId}`],
revalidate: 180,
}
)(params);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment