refactor: update meta cache only on update

This commit is contained in:
sup39 2024-01-23 09:53:34 +09:00
parent 58791e6e55
commit 145cba9ae5
Signed by: sup39
GPG key ID: 111C00916C1641E5
3 changed files with 6 additions and 4 deletions

View file

@ -1,4 +0,0 @@
import { fetchMeta } from "@/misc/backend-rs.js";
// refresh cache
setInterval(() => fetchMeta(true), 1000 * 10);

View file

@ -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");
}

View file

@ -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");