PHPackages                             scu2008/php-consistent-hash - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. scu2008/php-consistent-hash

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

scu2008/php-consistent-hash
===========================

a good php consistent hash helper

581PHP

Since Jun 12Pushed 10y ago2 watchersCompare

[ Source](https://github.com/scu2008/php-consistent-hash)[ Packagist](https://packagist.org/packages/scu2008/php-consistent-hash)[ RSS](/packages/scu2008-php-consistent-hash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#php-consistent-hash)

a good php consistent hash helper,一个用php写的一致性hash 助手,主要用于解决internet中的热点（hot spot）问题

特性
--

[](#特性)

- 平衡性(Balance)：平衡性是指哈希的结果能够尽可能分布到所有的缓冲中去，这样可以使得所有的缓冲空间都得到利用。很多哈希算法都能够满足这一条件。
- 单调性(Monotonicity)：单调性是指如果已经有一些内容通过哈希分派到了相应的缓冲中，又有新的缓冲加入到系统中。哈希的结果应能够保证原有已分配的内容可以被映射到原有的或者新的缓冲中去，而不会被映射到旧的缓冲集合中的其他缓冲区。
- 分散性(Spread)：在分布式环境中，终端有可能看不到所有的缓冲，而是只能看到其中的一部分。当终端希望通过哈希过程将内容映射到缓冲上时，由于不同终端所见的缓冲范围有可能不同，从而导致哈希的结果不一致，最终的结果是相同的内容被不同的终端映射到不同的缓冲区中。这种情况显然是应该避免的，因为它导致相同内容被存储到不同缓冲中去，降低了系统存储的效率。分散性的定义就是上述情况发生的严重程度。好的哈希算法应能够尽量避免不一致的情况发生，也就是尽量降低分散性。
- 负载(Load)：负载问题实际上是从另一个角度看待分散性问题。既然不同的终端可能将相同的内容映射到不同的缓冲区中，那么对于一个特定的缓冲区而言，也可能被不同的用户映射为不同 的内容。与分散性一样，这种情况也是应当避免的，因此好的哈希算法应能够尽量降低缓冲的负荷

---

类的基本说明
------

[](#类的基本说明)

- ConsistentHash 主类,实现对节点的添加与查找
- Crc32Hasher crc32方式
- Md5Hasher md5方式
- Sha1Hasher sha1方式

examples
--------

[](#examples)

```
  $hash = new ConsistentHash\ConsistentHash();
  $arr = ['10.7.0.1', '10.7.0.2', '10.7.0.3'];
  $hash->addTargets($arr);//添加多个节点
  $hash->lookup('hashkey');//输入特定的key通过相应的hash算法寻找到合适的节点
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/59efcf6b380e73239930262444e3a3a1781a0dfd290f85b8b797b0dc118ccd39?d=identicon)[zhufanmao](/maintainers/zhufanmao)

---

Top Contributors

[![hikenote](https://avatars.githubusercontent.com/u/8486259?v=4)](https://github.com/hikenote "hikenote (7 commits)")

### Embed Badge

![Health badge](/badges/scu2008-php-consistent-hash/health.svg)

```
[![Health](https://phpackages.com/badges/scu2008-php-consistent-hash/health.svg)](https://phpackages.com/packages/scu2008-php-consistent-hash)
```

###  Alternatives

[jaeger/querylist-phantomjs

QueryList Plugin: Use PhantomJS to crawl Javascript dynamically rendered pages.(headless WebKit ) 使用PhantomJS采集JavaScript动态渲染的页面

6124.3k2](/packages/jaeger-querylist-phantomjs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
