Files
formbricks/packages/lib/environment/cache.ts
Piyush Gupta 35b2d12e18 feat: Product Model Revamp (#4353)
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
2024-12-03 04:34:09 +00:00

27 lines
539 B
TypeScript

import { revalidateTag } from "next/cache";
interface RevalidateProps {
id?: string;
projectId?: string;
}
export const environmentCache = {
tag: {
byId(id: string) {
return `environments-${id}`;
},
byProjectId(projectId: string) {
return `projects-${projectId}-environments`;
},
},
revalidate({ id, projectId: projectId }: RevalidateProps): void {
if (id) {
revalidateTag(this.tag.byId(id));
}
if (projectId) {
revalidateTag(this.tag.byProjectId(projectId));
}
},
};