Files
formbricks-formbricks/packages/lib/user/cache.ts
Dhruwang Jariwala 5bf5825f30 feat: Onboarding for self hosting (#2722)
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2024-06-10 17:56:02 +00: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());
}
},
};