()
| 50 | |
| 51 | // 清理过期的缓存项 |
| 52 | cleanup(): void { |
| 53 | const now = Date.now(); |
| 54 | Array.from(this.cache.entries()).forEach(([key, item]) => { |
| 55 | if (now - item.timestamp > item.ttl) { |
| 56 | this.cache.delete(key); |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | export const cache = Cache.getInstance(); |