{"id":15568623,"url":"https://github.com/jayvdb/dns-cache","last_synced_at":"2025-09-04T12:34:49.249Z","repository":{"id":57423111,"uuid":"245803549","full_name":"jayvdb/dns-cache","owner":"jayvdb","description":"DNS lookup cache for Python using dnspython","archived":false,"fork":false,"pushed_at":"2021-10-26T23:57:05.000Z","size":85,"stargazers_count":20,"open_issues_count":20,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T00:04:14.936Z","etag":null,"topics":["diskcache","dns","dns-cache","dns-lookup","python","resolver"],"latest_commit_sha":null,"homepage":"","language":"Python","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/jayvdb.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":"2020-03-08T11:40:46.000Z","updated_at":"2025-03-12T03:00:09.000Z","dependencies_parsed_at":"2022-09-05T12:30:33.092Z","dependency_job_id":null,"html_url":"https://github.com/jayvdb/dns-cache","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayvdb%2Fdns-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayvdb%2Fdns-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayvdb%2Fdns-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayvdb%2Fdns-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jayvdb","download_url":"https://codeload.github.com/jayvdb/dns-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841150,"owners_count":20356441,"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":["diskcache","dns","dns-cache","dns-lookup","python","resolver"],"created_at":"2024-10-02T17:19:42.216Z","updated_at":"2025-03-16T07:32:23.189Z","avatar_url":"https://github.com/jayvdb.png","language":"Python","readme":"# dns-cache\n\n`dns-cache` is a Python client side DNS caching framework utilising\n[`dnspython`](https://github.com/rthalley/dnspython) v1.15+ for DNS\nand supports various local key stores, and provides caching of lookup failures,\nand configurable expiration of cached responses.\n\nSome reasons to use a client side cache include:\n- processing data containing many repeated invalid domains,\n- running a local DNS caching service is not practical or appropriate,\n- adding reporting of DNS activity performed within a job.\n\n## Installation\n\nThe recommended way to install `dns-cache` is by using pip as follows:\n\n`pip install dns-cache`\n\n## Getting started\n\nTo quickly benefit from client side dns-caching in your existing application, install the system resolver.\n\n```python\nimport dns_cache\nimport requests\n\ndns_cache.override_system_resolver()\n\nfor i in range(10):\n     requests.get('http://www.coala.io/')\n```\n\nIf you have a fast dns proxy, 10 requests will possibly show no performance improvement.\nEven 100 may not perform better in this contrived example.\n\nHowever when many parts of a system are performing lookups on the same DNS records, or where\nsessions are being closed and new ones created and need to access the same DNS records,\nthe difference becomes more noticable, especially in jobs which takes hours to run.\n\nFor long running jobs, use the `min_ttl` argument to increase the default if 5 minutes isnt sufficient.\nIt can be set to `dns_cache.NO_EXPIRY` for a ttl of one week, which is not recommended except when\naccompanied with custom cache expiration logic.\n\n## Key stores\n\nMultiple key stores are supported, and their dependencies need to added separately as required.\n\n1. `pickle` and [`pickle4`](https://github.com/moreati/pickle4) backport: `dns_cache.pickle.PickableCache`\n2. [`diskcache`](https://github.com/grantjenks/python-diskcache): `dns_cache.diskcache.DiskCache`\n3. [`stash.py`](https://github.com/fuzeman/stash.py/): `dns_cache.stash.StashCache`\n4. [`sqlitedict`](https://github.com/RaRe-Technologies/sqlitedict): `dns_cache.sqlitedict.SqliteDictCache`\n5. [`disk_dict`](https://github.com/AWNystrom/DiskDict): `dns_cache.disk_dict.DiskDictCache` (Python 2.7 only)\n\n`stash.py` support uses `pickle` or `jsonpickle` on Python 3, however only `jsonpickle` works on Python 2.7.\n\n## Caching additions\n\nThe following classes can be used separately or together.\n\n1. `dns_cache.resolver.AggressiveCachingResolver`: indexes all qnames in the response, increasing the number of keys,\n   but reducing the number of requests and cached responses when several related records are requested, such as a HTTP redirect\n   from www.foo.com to foo.com (or vis versa) where one is a CNAME point to the other.\n2. `dns_cache.resolver.ExceptionCachingResolver`: caches lookup failures.\n3. `dns_cache.hosts.HostsCache`: preloads hosts (e.g. `/etc/hosts`) into a cache\n\n**Note:** `dns_cache.override_system_resolver()` can be used to install a custom `resolver` or `cache`, which may\nbe derived from the above classes or your own implementation from scratch.  It preloads `/etc/hosts`.\n\n## Similar projects\n\nPython:\n1. [`velocity`](https://github.com/s0md3v/velocity) is a lighter weight approach, with a [`serious bug`](https://github.com/s0md3v/velocity/issues/2)\n2. [`dnsplug`](https://github.com/nresare/dnsplug), unfortunately not available on PyPI.\n\nOther:\n1. [`dnscache`](https://github.com/rs/dnscache) (Go)\n2. [`native-dns-cache`](https://github.com/tjfontaine/native-dns-cache) (Node)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayvdb%2Fdns-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayvdb%2Fdns-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayvdb%2Fdns-cache/lists"}