Velocity is an elegant DNS caching library for Python. It intercepts all the DNS/Protocol resolution calls and caches them. That's it, everything that makes network connections gets a performance boost.
Liked the project? Buy me a coffee.
Documentation
- Installation
- Getting started
- Managing local cache
- Manually caching hostnames
- Accessing cache databases
Installation
The recommended way to install velocity is by using pip as follows:
pip install velocity
Getting started
Velocity just needs to be imported to be activated. For example, the following program will start using cached DNS responses after the first request.
import requests
import velocity
for i in range(10):
requests.get('https://s0md3v.github.io')
Important: If you are using threads, consider caching the hostnames manually to prevent the database getting affected from race conditions.
Managing local cache
The cache can be stored locally. None of the following methods return anything or take arguments, just call them at will.
import velocity
velocity.flush_db() # deletes the local cache
velocity.save_db() # saves the in-memory cache locally
velocity.load_db() # loads the local cache into memory
Manually caching hostnames
A hostname can be cached manually as follows:
import velocity
velocity.cache(hostname)
Note: IPv6 address are mapped to IPv4 addresses by default, which shouldn't be a problem. To avoid this behaviour and use IPv6 address instead, add an reachable port number as
velocity.cache(hostname, port)
Accessing database
In-memory cache databases can be accessed with their respective variable names.
velocity.dns_cache: Contains {hostname:ip} pairsvelocity.addr_cache: Contains {hostname:getaddrinfo_object} pairs
Contributions & License
Feel free to report any bugs you encounter, request features, give suggestions and fix bugs.
Pull requests that do not imrpove velocity as a program will not be accepted. Such as typo fixes, adding .gitignore file,
pep8 styled code structure etc.
Licensed under the GPLv3, see LICENSE for more information.
Liked the project?
You can support the developer by leaving a tip.
Metadata
Release files for velocity 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| velocity-0.0.1.tar.gz | 17.7 kB | Without provenance | Details for velocity-0.0.1.tar.gz |
Release files / velocity-0.0.1.tar.gz
| Download URL | velocity-0.0.1.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ced3aea1f4b696472c65064c0d06a47dccac2b297b6383b9bc3592eae5a2f8e
|
|
BLAKE2b-256 checksum How to use checksums |
af3d45356d635c33fcbe375bb8cb11e2c419976f2e66bf14652ab6639a745536
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.17rc1
|
Security for velocity 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.