From 62f955a5f00fb880247affe9efe67f475f78b9a7 Mon Sep 17 00:00:00 2001 From: atridadl Date: Thu, 14 Dec 2023 17:11:07 -0700 Subject: [PATCH] Cache optimization --- .gitignore | 1 + app/routes/api.room.get.all.tsx | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 3f7bf98..7e21fce 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules /build /public/build .env +dump.rdb \ No newline at end of file diff --git a/app/routes/api.room.get.all.tsx b/app/routes/api.room.get.all.tsx index d19abe5..8ffa245 100644 --- a/app/routes/api.room.get.all.tsx +++ b/app/routes/api.room.get.all.tsx @@ -35,9 +35,10 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) { where: eq(rooms.userId, userId || ""), }) .then((roomList) => { - setCache(`kv_roomlist_${userId}`, roomList, "sp").then(() => { - send({ event: userId!, data: JSON.stringify(roomList) }); - }); + Promise.all([ + 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 || ""), }) .then((roomList) => { - setCache(`kv_roomlist_${userId}`, roomList, "sp").then(() => { - send({ event: userId!, data: JSON.stringify(roomList) }); - }); + Promise.all([ + setCache(`kv_roomlist_${userId}`, roomList, "sp"), + send({ event: userId!, data: JSON.stringify(roomList) }), + ]); }); } });