MichaCo / DnsClient.NET

DnsClient.NET is a simple yet very powerful and high performant open source library for the .NET Framework to do DNS lookups
https://dnsclient.michaco.net
Apache License 2.0
781 stars 137 forks source link

Move cache checks outside loop in ResolveQuery and ResolveQueryAsync #199

Closed williamb1024 closed 1 year ago

williamb1024 commented 1 year ago

Are you open to the idea of lifting cache checks outside of the server loop in LookupClient.ResolveQuery() and LookupClient.ResolveQueryAsync()?

There really is no point in performing the check once per-server unless you are expecting a request from a different context to have completed and updated the cache.

The cache check should be wrapped in a conditional ensuring that at least one server is included in the servers argument. This would ensure that the code continues to operate in the same manner as it does now.

MichaCo commented 1 year ago

A request to a server which might not have the answer can take several seconds sometimes. So yeah, in the meantime, the result might got cached.

What would be the advantage of moving the cache check outside of the loop? Also keep in mind that the overhead (time) doing the cache check is basically irrelevant.

williamb1024 commented 1 year ago

I agree the time savings would be negligible and insignificant in comparison to the time waiting for a server response. My primary reason for asking was to determine how open you'd be to moving things around in ResolveQuery and ResolveQueryAsync.

I'm going to close this and hopefully continue the conversation in the #198 issue instead.