* 检查缓存项是否存在
(key: string)
| 72 | * 检查缓存项是否存在 |
| 73 | */ |
| 74 | has(key: string): boolean { |
| 75 | const item = this.cache.get(key); |
| 76 | |
| 77 | if (!item) { |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | // 检查是否过期 |
| 82 | if (Date.now() - item.timestamp > item.ttl) { |
| 83 | this.cache.delete(key); |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | return true; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * 删除缓存项 |
no test coverage detected