(domain: string)
| 350 | parseMode: "html", |
| 351 | linkPreview: false |
| 352 | }); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | private async getCachedResult(domain: string): Promise<WhoisRecord | null> { |
| 357 | if (!this.db) return null; |
| 358 | |
| 359 | const cache = this.db.data.cache[domain.toLowerCase()]; |
| 360 | if (!cache) return null; |
| 361 | |
| 362 | // 检查缓存是否过期 |
| 363 | const cacheTime = new Date(cache.queryTime).getTime(); |
| 364 | const now = Date.now(); |
| 365 | const cacheHours = this.db.data.settings.cacheHours || 24; |
| 366 | |
| 367 | if (now - cacheTime > cacheHours * 60 * 60 * 1000) { |
| 368 | // 缓存过期,删除 |
| 369 | delete this.db.data.cache[domain.toLowerCase()]; |
| 370 | await this.db.write(); |
| 371 | return null; |
| 372 | } |
| 373 | |
| 374 | return cache; |
no test coverage detected