Open jayvdb opened 4 years ago
Can you please elaborate?
Sure.
I've created https://github.com/jayvdb/dns-cache , which is a much heavy alternative to velocity which suited my needs better anyway, and has a basic implementation of lookup failure caching at https://github.com/jayvdb/dns-cache/blob/83a3df0/dns_cache/resolver.py#L70 , and https://github.com/jayvdb/dns-cache/issues/9 is the first issue about making it more robust, however it has the added complication of using dnspython resolver. (fwiw, offtopic, I mentioned https://github.com/s0md3v/velocity/issues/2 in the README. I probably would have tried to fix it, except my needs outgrew velocity's apparent purpose/scope quite quickly)
For velocity approach, there are three exceptions in socket
which can be caught, negative result cached, and re-raised. (and possibly socket.error
on Python 2.7 but I dont know if catching that is useful)
velocity
has less opportunity to "safely" cache negative results, as it isnt able to see the raw DNS response, however there are still ways to make it a bit more robust, such as not re-using the very first cached entry if it is a lookup failure, as there is a higher chance that it could be a transient failure. Also cache expiration would help, but that is a separate feature ;-) It seems that velocity is more suited to usage where speed outweighs safety concerns - such as scripts where the user can simply re-start them if there was a problem, so cache expiration may not even be in scope.
It looks like resolution failures are not being cached.