Forráskód Böngészése

修改dns缓存时间

陈国伟 3 éve
szülő
commit
efb59f2535
1 módosított fájl, 4 hozzáadás és 1 törlés
  1. 4 1
      FastGithub.DomainResolve/DnsClient.cs

+ 4 - 1
FastGithub.DomainResolve/DnsClient.cs

@@ -31,7 +31,7 @@ namespace FastGithub.DomainResolve
 
 
         private readonly ConcurrentDictionary<string, SemaphoreSlim> semaphoreSlims = new();
         private readonly ConcurrentDictionary<string, SemaphoreSlim> semaphoreSlims = new();
         private readonly IMemoryCache dnsCache = new MemoryCache(Options.Create(new MemoryCacheOptions()));
         private readonly IMemoryCache dnsCache = new MemoryCache(Options.Create(new MemoryCacheOptions()));
-        private readonly TimeSpan dnsExpiration = TimeSpan.FromMinutes(2d);
+        private readonly TimeSpan dnsExpiration = TimeSpan.FromMinutes(1d);
         private readonly int resolveTimeout = (int)TimeSpan.FromSeconds(2d).TotalMilliseconds;
         private readonly int resolveTimeout = (int)TimeSpan.FromSeconds(2d).TotalMilliseconds;
 
 
         /// <summary>
         /// <summary>
@@ -108,6 +108,9 @@ namespace FastGithub.DomainResolve
                 {
                 {
                     value = await this.LookupCoreAsync(dns, domain, cancellationToken);
                     value = await this.LookupCoreAsync(dns, domain, cancellationToken);
                     this.dnsCache.Set(key, value, this.dnsExpiration);
                     this.dnsCache.Set(key, value, this.dnsExpiration);
+
+                    var items = string.Join(", ", value.Select(item => item.ToString()));
+                    this.logger.LogInformation($"dns://{dns}:{domain}->[{items}]");
                 }
                 }
                 return value;
                 return value;
             }
             }