Last change before work :)
This commit is contained in:
parent
5cb8a18b83
commit
06a5f05250
5 changed files with 8 additions and 8 deletions
|
@ -25,14 +25,14 @@ export const restRouter = createTRPCRouter({
|
|||
.input(z.void())
|
||||
.output(z.number())
|
||||
.query(async ({ ctx }) => {
|
||||
const cachedResult = await fetchCache<number>(`kv_votecount_admin`);
|
||||
const cachedResult = await fetchCache<number>(`kv_votecount`);
|
||||
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
} else {
|
||||
const votesCount = await ctx.prisma.vote.count();
|
||||
|
||||
await setCache(`kv_votecount_admin`, votesCount);
|
||||
await setCache(`kv_votecount`, votesCount);
|
||||
|
||||
return votesCount;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export const roomRouter = createTRPCRouter({
|
|||
},
|
||||
});
|
||||
if (room) {
|
||||
await invalidateCache(`kv_roomcount_admin`);
|
||||
await invalidateCache(`kv_roomcount`);
|
||||
await invalidateCache(`kv_roomlist_${ctx.session.user.id}`);
|
||||
|
||||
await publishToChannel(
|
||||
|
@ -215,8 +215,8 @@ export const roomRouter = createTRPCRouter({
|
|||
});
|
||||
|
||||
if (deletedRoom) {
|
||||
await invalidateCache(`kv_roomcount_admin`);
|
||||
await invalidateCache(`kv_votecount_admin`);
|
||||
await invalidateCache(`kv_roomcount`);
|
||||
await invalidateCache(`kv_votecount`);
|
||||
await invalidateCache(`kv_roomlist_${ctx.session.user.id}`);
|
||||
|
||||
await publishToChannel(
|
||||
|
|
|
@ -118,7 +118,7 @@ export const userRouter = createTRPCRouter({
|
|||
react: Goodbye({ name: user.name }),
|
||||
});
|
||||
|
||||
await invalidateCache(`kv_usercount_admin`);
|
||||
await invalidateCache(`kv_usercount`);
|
||||
await invalidateCache(`kv_userlist_admin`);
|
||||
|
||||
await publishToChannel(
|
||||
|
|
|
@ -85,7 +85,7 @@ export const voteRouter = createTRPCRouter({
|
|||
});
|
||||
|
||||
if (vote) {
|
||||
await invalidateCache(`kv_votecount_admin`);
|
||||
await invalidateCache(`kv_votecount`);
|
||||
await invalidateCache(`kv_votes_${input.roomId}`);
|
||||
|
||||
await publishToChannel(
|
||||
|
|
|
@ -66,7 +66,7 @@ export const authOptions: NextAuthOptions = {
|
|||
react: Welcome({ name: user.name }),
|
||||
});
|
||||
await invalidateCache(`kv_userlist_admin`);
|
||||
await invalidateCache(`kv_usercount_admin`);
|
||||
await invalidateCache(`kv_usercount`);
|
||||
|
||||
await publishToChannel(
|
||||
`stats`,
|
||||
|
|
Loading…
Add table
Reference in a new issue