PHPackages                             yiranzai/hash-dht - 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. yiranzai/hash-dht

ActiveLibrary

yiranzai/hash-dht
=================

PHP Distributed Hash Table

v1.0(7y ago)43MITPHPPHP ~7.1

Since Mar 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yiranzai/php-hash-dht)[ Packagist](https://packagist.org/packages/yiranzai/hash-dht)[ Docs](https://github.com/yiranzai/php-hash-dht)[ RSS](/packages/yiranzai-hash-dht/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

hash-dht
========

[](#hash-dht)

 [![](https://camo.githubusercontent.com/984b0f7f7f77bb45e13dc2f457a916e77a2d38cf43f69f2e2dbc7595b20d7afc/68747470733a2f2f63646e2e796972616e7a61692e636e2f796972616e7a61692f6c6f676f2f6d6f7573652f6d6f7573652e706e67)](https://camo.githubusercontent.com/984b0f7f7f77bb45e13dc2f457a916e77a2d38cf43f69f2e2dbc7595b20d7afc/68747470733a2f2f63646e2e796972616e7a61692e636e2f796972616e7a61692f6c6f676f2f6d6f7573652f6d6f7573652e706e67)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cc72dd37c8714176d816fd69b1045fcc05d1f0d6f28ec8c6e15998082497cde4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796972616e7a61692f686173682d6468742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yiranzai/hash-dht)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/6e9c2a8bfbeeba058c1a1150640fe376ffabb1a02a6612809dd74db2ca3de11d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f796972616e7a61692f7068702d686173682d6468742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/yiranzai/php-hash-dht)[![Coverage Status](https://camo.githubusercontent.com/bb2da204623b2fc949a3470c45b85b6aef7e3162f708040da7c2f04238e35a73/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f796972616e7a61692f7068702d686173682d6468742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/yiranzai/php-hash-dht/code-structure)[![Quality Score](https://camo.githubusercontent.com/18fd17bc9d380f7c5c0ebcd76c995feaa31b93c60d687890c87c5f04b1dfba53/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f796972616e7a61692f7068702d686173682d6468742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/yiranzai/php-hash-dht)[![Total Downloads](https://camo.githubusercontent.com/fe36f0f2c27d2c406ec1f987a879cedec8a0076259098528ea7cd3dc82229d10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796972616e7a61692f686173682d6468742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yiranzai/hash-dht)

PHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key.

Install
-------

[](#install)

Via Composer

```
$ composer require yiranzai/hash-dht
```

Usage
-----

[](#usage)

easy

### init

[](#init)

```
$hash = new Yiranzai\Dht\Hash();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer =  $hash->getLocation('key_one');
```

### Reuse it

[](#reuse-it)

You have to cache it and pass it in the next time you use it. Or use the `static::cache` I provided.

```
$hash = new Yiranzai\Dht\Hash();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer =  $hash->getLocation('key_one');
Yiranzai\Dht\Hash::cache($hash->toArray());
$hash = new Yiranzai\Dht\Hash(Yiranzai\Dht\Hash::getCache());
$dbServer =  $hash->getLocation('key_one');
```

### Delete Entity Node

[](#delete-entity-node)

Delete entity node

```
$hash = new Yiranzai\Dht\Hash();
$hash->deleteEntityNode('db_server_one');
```

### Change algo

[](#change-algo)

default algo is time33, [See more support](SUPPORT_ALGOS.md)

```
$hash = new Yiranzai\Dht\Hash();
$hash->algo('sha256');

//or

$hash = new Yiranzai\Dht\Hash(['algo' => YOUR_ALGO]);
```

### Change default cache path

[](#change-default-cache-path)

Change default cache path

```
$hash = new Yiranzai\Dht\Hash();
$hash->path(YOUR_PATH);

//or

$hash = new Yiranzai\Dht\Hash(['cachePath' => YOUR_PATH]);
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [yiranzai](https://github.com/yiranzai)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2622d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/131c451d3fbf74a922387ce2b4c1e0e2e282afcabe8f67a09fc9fa25bbb09799?d=identicon)[yiranzai](/maintainers/yiranzai)

---

Top Contributors

[![yiranzai](https://avatars.githubusercontent.com/u/20548510?v=4)](https://github.com/yiranzai "yiranzai (9 commits)")

---

Tags

dhthashphpphp7yiranzaihash-dht

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/yiranzai-hash-dht/health.svg)

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

PHPackages © 2026

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