mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-03 04:11:34 -06:00
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
34 lines
607 B
TypeScript
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());
|
|
}
|
|
},
|
|
};
|