Добавил периодическую очистку кэша

This commit is contained in:
Book Pauk
2019-03-11 15:59:05 +07:00
parent 89d9a90901
commit 5011e23050

View File

@@ -6,7 +6,7 @@ const connManager = require('../db/connManager');
class ReaderStorage {
constructor() {
this.storagePool = connManager.pool.readerStorage;
this.cache = {};
this.periodicCleanCache(3*3600*1000);//1 раз в 3 часа
}
async doAction(act) {
@@ -92,6 +92,14 @@ class ReaderStorage {
return {state: 'success'};
}
periodicCleanCache(timeout) {
this.cache = {};
setTimeout(() => {
this.periodicCleanCache(timeout);
}, timeout);
}
}
const readerStorage = new ReaderStorage();