PHPackages                             flexihash/flexihash - 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. flexihash/flexihash

ActiveLibrary

flexihash/flexihash
===================

Flexihash is a small PHP library which implements consistent hashing

v3.0.0(5y ago)366708.0k↓12.8%83[3 issues](https://github.com/pda/flexihash/issues)[1 PRs](https://github.com/pda/flexihash/pulls)5MITPHPPHP &gt;=7.2.0CI failing

Since Oct 16Pushed 4y ago39 watchersCompare

[ Source](https://github.com/pda/flexihash)[ Packagist](https://packagist.org/packages/flexihash/flexihash)[ Docs](https://github.com/pda/flexihash)[ RSS](/packages/flexihash-flexihash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (8)Versions (6)Used By (5)

Flexihash
=========

[](#flexihash)

[![Build Status](https://camo.githubusercontent.com/23c8793fb141a3dd05c386edcb3affd37ba8cc46299b33ae0bde7b2ba32e96b9/68747470733a2f2f7472617669732d63692e6f72672f7064612f666c657869686173682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pda/flexihash) [![Coverage Status](https://camo.githubusercontent.com/f89672edd0417dd38dbd61027bc80605e599f0b5e04d5e0d61643f2668e55eca/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7064612f666c657869686173682f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/pda/flexihash?branch=master)

Flexihash is a small PHP library which implements [consistent hashing](http://en.wikipedia.org/wiki/Consistent_hashing), which is most useful in distributed caching. It requires PHP5 and uses [PHPUnit](http://simpletest.org/) for unit testing.

Installation
------------

[](#installation)

[Composer](https://getcomposer.org/) is the recommended installation technique. You can find flexihash on [Packagist](https://packagist.org/packages/flexihash/flexihash) so installation is as easy as

```
composer require flexihash/flexihash

```

or in your `composer.json`

```
{
    "require": {
        "flexihash/flexihash": "^3.0.0"
    }
}
```

Usage
-----

[](#usage)

```
$hash = new Flexihash();

// bulk add
$hash->addTargets(['cache-1', 'cache-2', 'cache-3']);

// simple lookup
$hash->lookup('object-a'); // "cache-1"
$hash->lookup('object-b'); // "cache-2"

// add and remove
$hash
  ->addTarget('cache-4')
  ->removeTarget('cache-1');

// lookup with next-best fallback (for redundant writes)
$hash->lookupList('object', 2); // ["cache-2", "cache-4"]

// remove cache-2, expect object to hash to cache-4
$hash->removeTarget('cache-2');
$hash->lookup('object'); // "cache-4"
```

Tests
-----

[](#tests)

### Unit Test

[](#unit-test)

```
% vendor/bin/phpunit

```

### Benchmark Test

[](#benchmark-test)

```
% vendor/bin/phpunit tests/BenchmarkTest.php

```

Further Reading
---------------

[](#further-reading)

-
- [http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent\_hash.html](http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent_hash.html)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity58

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 58.1% 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.

###  Release Activity

Cadence

Every ~439 days

Total

5

Last Release

2111d ago

Major Versions

v1.0.0 → v2.0.02015-11-08

v2.0.2 → v3.0.02020-08-07

PHP version history (2 changes)v2.0.0PHP &gt;=5.4.0

v3.0.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c043ea4e6527fa8216a68888199b83147a146f99d5d756f986209872b902792?d=identicon)[dmnc](/maintainers/dmnc)

---

Top Contributors

[![dmnc](https://avatars.githubusercontent.com/u/144790?v=4)](https://github.com/dmnc "dmnc (43 commits)")[![serima](https://avatars.githubusercontent.com/u/1130921?v=4)](https://github.com/serima "serima (17 commits)")[![pda](https://avatars.githubusercontent.com/u/15759?v=4)](https://github.com/pda "pda (12 commits)")[![myxobek](https://avatars.githubusercontent.com/u/10741404?v=4)](https://github.com/myxobek "myxobek (1 commits)")[![sergeyklay](https://avatars.githubusercontent.com/u/1256298?v=4)](https://github.com/sergeyklay "sergeyklay (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/flexihash-flexihash/health.svg)

```
[![Health](https://phpackages.com/badges/flexihash-flexihash/health.svg)](https://phpackages.com/packages/flexihash-flexihash)
```

PHPackages © 2026

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