A lightweight DNS caching library for Node.js that wraps the built-in dns.lookup and dns.promises.lookup with a TTL-based cache. Current stable version is 0.0.4, released as a single module with TypeScript types. It provides a drop-in replacement for Node.js DNS resolution with configurable cache size and TTL. Key differentiators: same API as Node's dns module, supports callback and promise variants, optional global patching, and no external dependencies. Release cadence is low; package is minimal and focused.
npm install cached-dnsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates callback lookup, promise lookup, and usage with http.get.
Avoid using patchGlobal() for persistent changes; pass lookup function explicitly.
Use lookupPromise for new projects; callback API is stable but not recommended.
Be aware that cache is per-process; consider external caching if persistence is needed.
Wrap calls in try-catch when using promises, or handle errors in callbacks as usual.
Run 'npm install cached-dns' in your project root.
Use `import { lookup } from 'cached-dns'` instead of `import lookup from 'cached-dns'`.Import individual functions: `import { lookup } from 'cached-dns'`.No dependency data recorded yet.