@vates/cached-dns.lookup
Cached implementation of dns.lookup
Install
Installation of the npm package:
> npm install --save @vates/cached-dns.lookup
Usage
Node does not cache queries to dns.lookup
, which can leads application doing a lot of connections to have perf issues and to saturate Node threads pool.
This library attemps to mitigate these problems by providing a version of this function with a version short cache, applied on both errors and results.
Limitation: verbatim: false
option is not supported.
I has exactly the same API as the native method and can be used directly:
import { createCachedLookup } from '@vates/cached-dns.lookup'
const lookup = createCachedLookup()
lookup('example.net', { all: true, family: 0 }, (error, result) => {
if (error != null) {
return console.warn(error)
}
console.log(result)
})
Or it can be used to replace the native implementation and speed up the whole app:
const restore = createCachedLookup().patchGlobal()
restore()
Contributions
Contributions are very welcomed, either on the documentation or on
the code.
You may:
- report any issue
you've encountered;
- fork and create a pull request.
License
ISC © Vates SAS