Files
formbricks-formbricks/apps/web/lib/user/cache.ts
T
2025-04-21 15:57:54 +02:00

34 lines
607 B
TypeScript

import { revalidateTag } from "next/cache";
interface RevalidateProps {
id?: string;
email?: string;
count?: boolean;
}
export const userCache = {
tag: {
byId(id: string) {
return `users-${id}`;
},
byEmail(email: string) {
return `users-${email}`;
},
byCount() {
return "users-count";
},
},
revalidate({ id, email, count }: RevalidateProps): void {
if (id) {
revalidateTag(this.tag.byId(id));
}
if (email) {
revalidateTag(this.tag.byEmail(email));
}
if (count) {
revalidateTag(this.tag.byCount());
}
},
};