GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tcpcloud/debian-python-consistent-hash

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
consistent_hash.egg-info
consistent_hash.egg-info
 
 
consistent_hash
consistent_hash
 
 
PKG-INFO
PKG-INFO
 
 
README
README
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 

Repository files navigation

consistent-hash
===============

Implements consistent hashing that can be used when the number of server nodes can increase or decrease.The algorithm that is used for consistent hashing is the same as libketama <https://github.com/RJ/ketama>

Usage
===============
It's so easy to use^_^::

    from consistent_hash import ConsistentHash
    
    # You can construct consistent hash with the below three ways
    con_hash = ConsistentHash({'192.168.0.101:11212':1, '192.168.0.102:11212':2, '192.168.0.103:11212':1})
    # Or
    con_hash = ConsistentHash(['192.168.0.101:11212', '192.168.0.102:11212', '192.168.0.103:11212']))
    # Or
    con_hash = ConsistentHash('192.168.0.101:11212')
    
    # Add servers to hash ring
    con_hash.add_nodes({'192.168.0.104:11212':1})
    # Get a server via the key of object
    server = con_hash.get_node('my_key')
    # Delete the server from hash ring, you don't need to indicate weights
    con_hash.del_nodes(['192.168.0.102:11212', '192.168.0.104:11212'])


Unit test
===============
- Firstly, install nose which extends unittest to make testing easier::

        pip install nose
    
    
- Then, run tests::
        
        # Option -s any stdout output will be printed immediately
        # and -v be more verbose
        nosetests -s -v


More information about nose <https://nose.readthedocs.org/en/latest/>

About

No description, website, or topics provided.

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

6 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.