dns-java icon indicating copy to clipboard operation
dns-java copied to clipboard

Provide a way to turn off response caching

Open ns476 opened this issue 7 years ago • 2 comments

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?

ns476 avatar Jul 26 '16 11:07 ns476

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.

pettermahlen avatar Aug 01 '16 12:08 pettermahlen

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.

ccampo133 avatar Jan 07 '18 15:01 ccampo133