mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 18:30:32 -06:00
26 lines
584 B
TypeScript
26 lines
584 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
environmentId?: string;
|
|
}
|
|
|
|
export const insightCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `documentGroups-${id}`;
|
|
},
|
|
byEnvironmentId(environmentId: string) {
|
|
return `environments-${environmentId}-documentGroups`;
|
|
},
|
|
},
|
|
revalidate: ({ id, environmentId }: RevalidateProps): void => {
|
|
if (id) {
|
|
revalidateTag(insightCache.tag.byId(id));
|
|
}
|
|
if (environmentId) {
|
|
revalidateTag(insightCache.tag.byEnvironmentId(environmentId));
|
|
}
|
|
},
|
|
};
|