mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-05 02:58:36 -06:00
35 lines
711 B
TypeScript
35 lines
711 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
productId?: string;
|
|
userId?: string;
|
|
}
|
|
|
|
export const environmentCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `environments-${id}`;
|
|
},
|
|
byProductId(productId: string) {
|
|
return `products-${productId}-environments`;
|
|
},
|
|
byUserId(userId: string) {
|
|
return `users-${userId}-environments`;
|
|
},
|
|
},
|
|
revalidate({ id, productId, userId }: RevalidateProps): void {
|
|
if (id) {
|
|
revalidateTag(this.tag.byId(id));
|
|
}
|
|
|
|
if (productId) {
|
|
revalidateTag(this.tag.byProductId(productId));
|
|
}
|
|
|
|
if (userId) {
|
|
revalidateTag(this.tag.byUserId(userId));
|
|
}
|
|
},
|
|
};
|