Browse Source

Add option for database cache size

pull/6/head
Menci 5 years ago
parent
commit
e946b931c9
  1. 3
      config-example.json
  2. 4
      models/common.ts
  3. 4
      models/problem.ts

3
config-example.json

@ -7,7 +7,8 @@
"username": "syzoj",
"password": "@DATABASE_PASSWORD@",
"host": "127.0.0.1",
"migrated_to_typeorm": true
"migrated_to_typeorm": true,
"cache_size": 1000
},
"logo": {
"url": null,

4
models/common.ts

@ -2,6 +2,8 @@ import * as TypeORM from "typeorm";
import * as LRUCache from "lru-cache";
import * as DeepCopy from "deepcopy";
declare var syzoj: any;
interface Paginater {
pageCnt: number;
perPage: number;
@ -23,7 +25,7 @@ const caches: Map<string, LRUCache<number, Model>> = new Map();
function ensureCache(modelName) {
if (!caches.has(modelName)) {
caches.set(modelName, new LRUCache({
max: 500
max: syzoj.config.db.cache_size
}));
}

4
models/problem.ts

@ -194,7 +194,9 @@ import * as util from "util";
import * as LRUCache from "lru-cache";
import * as DeepCopy from "deepcopy";
const problemTagCache = new LRUCache<number, number[]>();
const problemTagCache = new LRUCache<number, number[]>({
max: syzoj.config.db.cache_size
});
enum ProblemType {
Traditional = "traditional",

Loading…
Cancel
Save