{"id":21140678,"url":"https://github.com/vivek-26/dns-cached","last_synced_at":"2026-05-20T06:03:47.221Z","repository":{"id":57213658,"uuid":"141023802","full_name":"vivek-26/dns-cached","owner":"vivek-26","description":"DNS Caching using Memoization for Node.js","archived":false,"fork":false,"pushed_at":"2018-08-21T17:43:27.000Z","size":1453,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T07:35:57.578Z","etag":null,"topics":["cache","dns","memoize","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vivek-26.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-15T11:59:28.000Z","updated_at":"2018-08-21T17:43:29.000Z","dependencies_parsed_at":"2022-08-29T02:10:30.371Z","dependency_job_id":null,"html_url":"https://github.com/vivek-26/dns-cached","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-26%2Fdns-cached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-26%2Fdns-cached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-26%2Fdns-cached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-26%2Fdns-cached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vivek-26","download_url":"https://codeload.github.com/vivek-26/dns-cached/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243581092,"owners_count":20314167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","dns","memoize","nodejs"],"created_at":"2024-11-20T07:17:11.610Z","updated_at":"2026-05-20T06:03:47.153Z","avatar_url":"https://github.com/vivek-26.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## dns-cached\n\n#### Caching DNS Responses using Memoization technique.\n\n[![Build Status](https://travis-ci.org/vivek-26/dns-cached.svg?branch=master)](https://travis-ci.org/vivek-26/dns-cached)\n[![Coverage Status](https://coveralls.io/repos/github/vivek-26/dns-cached/badge.svg?branch=master)](https://coveralls.io/github/vivek-26/dns-cached?branch=master)\n\n## Installation\n\n`npm install dns-cached`\n\n## Example\n\n```js\nconst dnsCached = require('dns-cached');\nconst dns = require('dns');\nconst util = require('util');\n\nconst cache = dnsCached(5, { maxSize: 500 });\ncache.overrideMethods('resolve'); /* Override/Memoize DNS Resolve */\nconst dnsResolve = util.promisify(dns.resolve);\n\nasync function run() {\n  console.log('resolve(\"google.com\")');\n  for (let i = 0; i \u003c 3; i++) {\n    console.time('resolve');\n    console.log('IP: ', await dnsResolve('google.com'));\n    console.timeEnd('resolve');\n  }\n}\nrun().catch(console.error);\ncache.flush(); /* Clear all timers */\n```\n\n```\n% node index.js\nresolve(\"google.com\")\nIP:  [ '172.217.161.14' ]\nresolve: 47.908ms\nIP:  [ '172.217.161.14' ]\nresolve: 1.664ms\nIP:  [ '172.217.161.14' ]\nresolve: 0.173ms\n```\n\n## Usage\n\n```js\nconst dnsCached = require('dns-cached');\n/**\n * dnsCached(ttl, { maxSize })\n * ttl --\u003e Time to live in minutes. Default: 1\n * maxSize --\u003e Maximum number of items to store in cache. Default: 1000\n */\nconst cache = dnsCached(5, { maxSize: 500 });\n\n/* Override/Memoize all dns methods */\ncache.overrideMethods();\n\n/* Override/Memoize a single dns method */\ncache.overrideMethods('lookup');\n\n/* Override/Memoize a list of dns methods */\ncache.overrideMethods(['lookup', 'resolve']);\n\n/* Flushing cache (if needed) */\ncache.flush();\n```\n\n## Docs\n\n[Click here](https://vivek-26.github.io/dns-cached/) to view project documentation.\n\n## Running tests\n\n`npm test` or `npm run test`\n\n## Versioning\n\n[SemVer](https://semver.org/) is used for versioning. For the versions available, see the [tags](https://github.com/vivek-26/dns-cached/tags) on this repository.\n\n## License\n\nThis project is licensed under the `MIT License` - see the [LICENSE](https://github.com/vivek-26/dns-cached/blob/master/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivek-26%2Fdns-cached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvivek-26%2Fdns-cached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivek-26%2Fdns-cached/lists"}