Git Product home page Git Product logo

php_hashtable's Introduction

一致性hash演示

演示地址: http://ht.hotfive.cn/

php_hashTable

  1. php hashTable的实现,
  2. hash码冲突的解决方法,
  3. 一致性hash的php实现

一致性hash算法演示(服务端要求php环境)

这只是一个简单版本,纯供个人演示与理解使用,建议

  1. fork 该项目
  2. clone 到本地
  3. 将consistency_hash放到web环境下面,一定要可以使用IP|域名能访问到, 因为需要请求php端的hash算法  1. 配置完成之后,需要在js/hash.js中的$.get()方法中修改下你本地服务器的地址,否则不能动态添加 注意  
  4. 在浏览器中访问index.html页面可看到效果

接下来要做的

  1. 添加localstorage
  2. 添加条形hash桶的显示

php_hashtable's People

Contributors

wjcgithub avatar

Stargazers

 avatar Zhigang.li avatar guanguans avatar Iqbal Rifai avatar Allen avatar Ammar Faizi avatar sitfon avatar royee avatar zhuxiaoyu avatar  avatar  avatar changzhongzhong avatar darren avatar

Forkers

sitfon x12311231

php_hashtable's Issues

不解决冲突的hashtable,在做hashcode时候存在负数bug

hashTable\HashTable.php文件,hashFunc方法,会生成一个负数,在SplFixedArray数组中没有负数范围
建议改为如下:

private function hashFunc($key){
            $sum = crc32($key);
            $index = $sum % $this->size;
            if($index<0){
                return $index + $this->size;
            }
            return $index;
        }

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.