缓存清理

This commit is contained in:
Jerry 2025-05-20 18:32:31 +08:00
parent fb9be8ded7
commit 36c5a2ebea

View File

@ -5,6 +5,17 @@ import logger from '../../utils/core/logger';
class WordsService {
private wordCache: Record<string, string[]> = {}; //缓存
private readonly clearIntervalMs = 30 * 60 * 1000; //30min
constructor() {
this.startAutoClear();
}
private startAutoClear() {
setInterval(() => {
logger.info('[WordsService] Clearing wordCache..');
this.wordCache = {};
}, this.clearIntervalMs);
}
/**
* json到内存&