PHPackages                             yiranzai/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yiranzai/dht

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

yiranzai/dht
============

PHP Distributed Hash Table

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

Since Mar 8Pushed 7y ago2 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (1)

php-dht
=======

[](#php-dht)

 [![](https://camo.githubusercontent.com/bb9f23e60884ec57deaf2df4bf70249cdca96648110db82b20594b0e6c494dee/68747470733a2f2f63646e2e796972616e7a61692e636e2f796972616e7a61692f6c6f676f2f6d6f7573652f6d6f757365342e706e67)](https://camo.githubusercontent.com/bb9f23e60884ec57deaf2df4bf70249cdca96648110db82b20594b0e6c494dee/68747470733a2f2f63646e2e796972616e7a61692e636e2f796972616e7a61692f6c6f676f2f6d6f7573652f6d6f757365342e706e67)

[![Latest Version on Packagist](https://camo.githubusercontent.com/14144f146f8d3061637b1214414a81de37aef63366781468441579f71ed3171e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796972616e7a61692f6468742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yiranzai/dht)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/df7024f7013867e73d250c5f622bd15adcbcc588f5c2255501a2239267688764/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f796972616e7a61692f7068702d6468742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/yiranzai/php-dht)[![Coverage Status](https://camo.githubusercontent.com/c7e042003869cd690d58039607e5e7e1c4df428c073d819dc942ebb7ee76f7a4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f796972616e7a61692f7068702d6468742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/yiranzai/php-dht/code-structure)[![Quality Score](https://camo.githubusercontent.com/7432231a43c9cabc3466204ded601d0a879f3c0efed4b3617e64c7948ef7b249/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f796972616e7a61692f7068702d6468742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/yiranzai/php-dht)[![Total Downloads](https://camo.githubusercontent.com/4ee33dce989100ebab8a8cb29efb8f982acb567062c6462c9a3bbcdac713c878/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796972616e7a61692f6468742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yiranzai/dht)

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

You have to cache it and pass it in the next time you use it.

Install
-------

[](#install)

Via Composer

```
$ composer require yiranzai/dht
```

Usage
-----

[](#usage)

easy

### init

[](#init)

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

//or

$dhtOne = new Yiranzai\Dht\Dht([
    'virtualNodeNum' => 3,
    'algo'           => 'sha256',
]);
$dhtOne->addEntityNode('db_server_one');
```

### Reuse it

[](#reuse-it)

You have to cache it and pass it in the next time you use it.

```
$hash = new Yiranzai\Dht\Dht();
$hash->addEntityNode('db_server_one')->addEntityNode('db_server_two');
$dbServer =  $hash->getLocation('key_one');
$cache = $hash->toArray();
// please cache this data
$hash = new Yiranzai\Dht\Dht($cache);
$dbServer =  $hash->getLocation('key_one');
```

### Delete Entity Node

[](#delete-entity-node)

Delete entity node

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

### Change algo

[](#change-algo)

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

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

//or

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

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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

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

2625d 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 (5 commits)")

---

Tags

dhtphpphp7yiranzaidht

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[spatie/calendar-links

Generate add to calendar links for Google, iCal and other calendar systems

1.0k7.0M8](/packages/spatie-calendar-links)[monsieurbiz/sylius-rich-editor-plugin

A Rich Editor plugin for Sylius.

75380.8k6](/packages/monsieurbiz-sylius-rich-editor-plugin)[naucon/breadcrumbs

The breadcrumb package helps to integrate a common breadcrumb navigation into a web application. The package includes two components: A breadcrumbs class to add breadcrumb elements and a breadcrumbs helper to render html markup in php or smarty templates.

1225.4k](/packages/naucon-breadcrumbs)

PHPackages © 2026

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