{"id":15029164,"url":"https://github.com/yiranzai/php-dht","last_synced_at":"2025-07-26T02:06:21.278Z","repository":{"id":57087367,"uuid":"174500523","full_name":"yiranzai/php-dht","owner":"yiranzai","description":"PHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key. (You need to find a way to cache your node information.)","archived":false,"fork":false,"pushed_at":"2019-03-12T12:14:34.000Z","size":15,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T22:25:12.758Z","etag":null,"topics":["dht","php","php7"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiranzai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-08T08:42:52.000Z","updated_at":"2024-12-25T11:19:28.000Z","dependencies_parsed_at":"2022-08-24T12:50:59.342Z","dependency_job_id":null,"html_url":"https://github.com/yiranzai/php-dht","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiranzai%2Fphp-dht","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiranzai%2Fphp-dht/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiranzai%2Fphp-dht/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiranzai%2Fphp-dht/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiranzai","download_url":"https://codeload.github.com/yiranzai/php-dht/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107304,"owners_count":21048897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dht","php","php7"],"created_at":"2024-09-24T20:09:51.846Z","updated_at":"2025-04-09T20:32:19.612Z","avatar_url":"https://github.com/yiranzai.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-dht\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://cdn.yiranzai.cn/yiranzai/logo/mouse/mouse4.png\" alt=\"\" width=\"20%\"\u003e\n\u003c/p\u003e\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nPHP Distributed Hash Table, Suitable for assisting in finding distributed nodes corresponding to key.\n\nYou have to cache it and pass it in the next time you use it.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require yiranzai/dht\n```\n\n## Usage\n\neasy\n\n### init\n\n``` php\n$hash = new Yiranzai\\Dht\\Dht();\n$hash-\u003eaddEntityNode('db_server_one')-\u003eaddEntityNode('db_server_two');\n$dbServer =  $hash-\u003egetLocation('key_one');\n\n//or\n\n$dhtOne = new Yiranzai\\Dht\\Dht([\n    'virtualNodeNum' =\u003e 3,\n    'algo'           =\u003e 'sha256',\n]);\n$dhtOne-\u003eaddEntityNode('db_server_one');\n```\n\n### Reuse it\n\nYou have to cache it and pass it in the next time you use it.\n\n```php\n$hash = new Yiranzai\\Dht\\Dht();\n$hash-\u003eaddEntityNode('db_server_one')-\u003eaddEntityNode('db_server_two');\n$dbServer =  $hash-\u003egetLocation('key_one');\n$cache = $hash-\u003etoArray();\n// please cache this data\n$hash = new Yiranzai\\Dht\\Dht($cache);\n$dbServer =  $hash-\u003egetLocation('key_one');\n```\n\n### Delete Entity Node\n\nDelete entity node\n\n```php\n$hash = new Yiranzai\\Dht\\Dht();\n$hash-\u003edeleteEntityNode('db_server_one');\n```\n\n### Change algo\n\ndefault algo is time33, [See more support](SUPPORT_ALGOS.md)\n\n```php\n$hash = new Yiranzai\\Dht\\Dht();\n$hash-\u003ealgo('sha256');\n\n//or\n\n$hash = new Yiranzai\\Dht\\Dht(['algo' =\u003e YOUR_ALGO]);\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email wuqingdzx@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [yiranzai][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/yiranzai/dht.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/yiranzai/php-dht/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/yiranzai/php-dht.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/yiranzai/php-dht.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/yiranzai/dht.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/yiranzai/dht\n[link-travis]: https://travis-ci.org/yiranzai/php-dht\n[link-scrutinizer]: https://scrutinizer-ci.com/g/yiranzai/php-dht/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/yiranzai/php-dht\n[link-downloads]: https://packagist.org/packages/yiranzai/dht\n[link-author]: https://github.com/yiranzai\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiranzai%2Fphp-dht","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiranzai%2Fphp-dht","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiranzai%2Fphp-dht/lists"}