dns-java
dns-java copied to clipboard
Provide a way to turn off response caching
First off, many thanks for this library - it's great, very easy to use!
It would be nice if there was a way to robustly turn off all response caching. DnsSrvResolverBuilder
provides the cacheLookups
option, but it looks like that only controls caching of Lookup
instances - not caching of the actual responses, as dnsjava has a response cache shared between instances by default.
We were able to work around this by running:
Lookup.getDefaultCache(DClass.IN).setMaxCache(0)
Lookup.getDefaultCache(DClass.IN).setMaxNCache(0)
before performing any requests, but perhaps SimpleLookupFactory
should set the cache on its Lookup
instances to one which doesn't perform any caching?
That sounds like a generally useful feature - would you have time to provide a PR? It's not likely that we'll be able to invest time into implementing it.
I think that caching Lookup instances and caching DNS responses are different things; the Lookup caching is mostly done for thread safety. So not caching DNS responses should then be a different setting.
Just ran into this. Thanks for the workaround... the design of DNSJava is... questionable, to say the least. I'll look into providing a PR.