From 145cba9ae5bbd64593843f3d2ba11cfe3381b83e Mon Sep 17 00:00:00 2001 From: sup39 Date: Tue, 23 Jan 2024 09:53:34 +0900 Subject: [PATCH] refactor: update meta cache only on update --- packages/backend/src/misc/fetch-meta.ts | 4 ---- .../backend/src/server/api/endpoints/admin/accounts/hosted.ts | 3 +++ .../backend/src/server/api/endpoints/admin/update-meta.ts | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 packages/backend/src/misc/fetch-meta.ts diff --git a/packages/backend/src/misc/fetch-meta.ts b/packages/backend/src/misc/fetch-meta.ts deleted file mode 100644 index c31e2e89..00000000 --- a/packages/backend/src/misc/fetch-meta.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { fetchMeta } from "@/misc/backend-rs.js"; - -// refresh cache -setInterval(() => fetchMeta(true), 1000 * 10); diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts b/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts index fd4ad940..c5b4783c 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts @@ -2,6 +2,7 @@ import config from "@/config/index.js"; import { Meta } from "@/models/entities/meta.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { @@ -120,6 +121,8 @@ export default define(meta, paramDef, async (ps, me) => { } else { await transactionalEntityManager.save(Meta, set); } + // update meta cache + fetchMeta(true); }); insertModerationLog(me, "updateMeta"); } diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index f0e83192..ce803bb3 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -1,6 +1,7 @@ import { Meta } from "@/models/entities/meta.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { @@ -571,6 +572,8 @@ export default define(meta, paramDef, async (ps, me) => { } else { await transactionalEntityManager.save(Meta, set); } + // update meta cache + fetchMeta(true); }); insertModerationLog(me, "updateMeta");