perf: cache stats (close #75)
This commit is contained in:
parent
14567b9ece
commit
3e663f975e
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
import { Instances, Notes, Users } from "@/models/index.js";
|
||||
import define from "../define.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { Cache } from "@/misc/cache.js";
|
||||
|
||||
export const meta = {
|
||||
requireCredential: false,
|
||||
|
@ -60,7 +61,7 @@ export const paramDef = {
|
|||
required: [],
|
||||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async () => {
|
||||
const stats = async () => {
|
||||
const [
|
||||
notesCount,
|
||||
originalNotesCount,
|
||||
|
@ -107,4 +108,10 @@ export default define(meta, paramDef, async () => {
|
|||
driveUsageLocal,
|
||||
driveUsageRemote,
|
||||
};
|
||||
};
|
||||
|
||||
const cache = new Cache<Awaited<ReturnType<typeof stats>>>("stats", 60 * 10);
|
||||
|
||||
export default define(meta, paramDef, async () => {
|
||||
return await cache.fetch(null, () => stats());
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue