feat(dnscache): dns cache entries are now flushable

This commit is contained in:
fallenbagel
2025-02-23 04:18:11 +08:00
committed by gauthier-th
parent 18e935d0bb
commit bb47dc6c02
5 changed files with 78 additions and 9 deletions

View File

@@ -895,7 +895,25 @@ class DnsCacheManager {
};
}
clear() {
clearHostname(hostname: string): void {
if (!hostname || hostname.length === 0) {
return;
}
if (this.cache.has(hostname)) {
this.cache.delete(hostname);
logger.debug(`Cleared DNS cache entry for ${hostname}`, {
label: 'DNSCache',
});
}
}
clear(hostname?: string): void {
if (hostname && hostname.length > 0) {
this.clearHostname(hostname);
return;
}
this.cache.clear();
this.stats.hits = 0;
this.stats.misses = 0;