Git Product home page Git Product logo

velocity's Introduction

velocity

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.

Documentation

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} pairs
  • velocity.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.

velocity's People

Contributors

s0md3v avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.