Node.js dns.resolve() vs dns.lookup()

前端 未结 2 1669
暗喜
暗喜 2020-12-20 11:55

I need to lookup a given host to its corresponding IP in Node.js. There seems to be two native methods of doing this:

> dns.resolve(\'google.com\', (error         


        
2条回答
  •  既然无缘
    2020-12-20 12:21

    @mscdex answer is really full and explaining. I may add an info about approach we use to bypass thread blocking.

    We developed a module that replaces/extends node's dns.lookup method. Module caches responses, has multi-records resolving and TTL support. Also we have good unit and functional tests with 100% coverage. Module was tested in production and highload environments. Under MIT license. Here it is: https://github.com/LCMApps/dns-lookup-cache

    If you need support of lookup method but don't work negative effects like blocking of application or responses slow downs you may use our module. I believe it will help!

提交回复
热议问题