mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-10 08:49:54 -06:00
27 lines
528 B
TypeScript
27 lines
528 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
productId?: string;
|
|
}
|
|
|
|
export const environmentCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `environments-${id}`;
|
|
},
|
|
byProductId(productId: string) {
|
|
return `products-${productId}-environments`;
|
|
},
|
|
},
|
|
revalidate({ id, productId }: RevalidateProps): void {
|
|
if (id) {
|
|
revalidateTag(this.tag.byId(id));
|
|
}
|
|
|
|
if (productId) {
|
|
revalidateTag(this.tag.byProductId(productId));
|
|
}
|
|
},
|
|
};
|