Cache optimization

This commit is contained in:
Atridad Lahiji 2023-12-14 17:11:07 -07:00
parent 0114d534bb
commit 62f955a5f0
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ node_modules
/build /build
/public/build /public/build
.env .env
dump.rdb

View file

@ -35,9 +35,10 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
where: eq(rooms.userId, userId || ""), where: eq(rooms.userId, userId || ""),
}) })
.then((roomList) => { .then((roomList) => {
setCache(`kv_roomlist_${userId}`, roomList, "sp").then(() => { Promise.all([
send({ event: userId!, data: JSON.stringify(roomList) }); setCache(`kv_roomlist_${userId}`, roomList, "sp"),
}); send({ event: userId!, data: JSON.stringify(roomList) }),
]);
}); });
} }
}); });
@ -59,9 +60,10 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
where: eq(rooms.userId, userId || ""), where: eq(rooms.userId, userId || ""),
}) })
.then((roomList) => { .then((roomList) => {
setCache(`kv_roomlist_${userId}`, roomList, "sp").then(() => { Promise.all([
send({ event: userId!, data: JSON.stringify(roomList) }); setCache(`kv_roomlist_${userId}`, roomList, "sp"),
}); send({ event: userId!, data: JSON.stringify(roomList) }),
]);
}); });
} }
}); });