{"id":23842369,"url":"https://github.com/php-toolkit/pool","last_synced_at":"2025-02-22T05:23:31.426Z","repository":{"id":57071732,"uuid":"142953003","full_name":"php-toolkit/pool","owner":"php-toolkit","description":"A simple resource pool library of the php","archived":false,"fork":false,"pushed_at":"2018-12-12T15:24:25.000Z","size":74,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-02T18:41:33.077Z","etag":null,"topics":["pool","resource-pool"],"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/php-toolkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-31T02:40:34.000Z","updated_at":"2023-12-27T06:39:22.000Z","dependencies_parsed_at":"2022-08-24T14:54:32.101Z","dependency_job_id":null,"html_url":"https://github.com/php-toolkit/pool","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Fpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Fpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Fpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-toolkit%2Fpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-toolkit","download_url":"https://codeload.github.com/php-toolkit/pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240129441,"owners_count":19752353,"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":["pool","resource-pool"],"created_at":"2025-01-02T18:38:20.389Z","updated_at":"2025-02-22T05:23:31.403Z","avatar_url":"https://github.com/php-toolkit.png","language":"PHP","readme":"# 资源池\n\n[![License](https://img.shields.io/packagist/l/toolkit/pool.svg?style=flat-square)](LICENSE)\n[![Php Version](https://img.shields.io/badge/php-%3E=7.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/toolkit/pool)\n[![Latest Stable Version](http://img.shields.io/packagist/v/toolkit/pool.svg)](https://packagist.org/packages/toolkit/pool)\n\n\u003e 资源池使用在 **常住进程的服务** 中才有用。比如用 swoole/workman 创建的应用\n\n使用池可实现 数据库连接池、redis连接池等，减少对服务的过多的连接/断开带来的额外资源消耗。\n\n- 基于swoole的实现  \n\n本仓库主要是做一些关于连接池的基础接口方法的抽象定义，并没有完整具体的实现。\n\n\u003e 具体的实现请查看： https://github.com/swokit/connection-pool.git\n\n## 项目地址\n\n- **github** https://github.com/php-toolkit/pool.git\n\n## 安装\n\n- 使用 `composer require toolkit/pool`\n- 使用 `composer.json`\n\n```\n\"toolkit/pool\": \"dev-master\"\n```\n\n然后执行: `composer update`\n\n- 直接拉取\n\n```\ngit clone https://git.oschina.net/inhere/php-resource-pool.git // git@osc\ngit clone https://github.com/inhere/php-resource-pool.git // github\n```\n\n## 使用\n\n```php\n\nuse Toolkit\\Pool\\Raw\\ResourcePool;\n\n$rpl = new ResourcePool([\n    'initSize' =\u003e 2,\n    'maxSize' =\u003e 2,\n    'driverOptions' =\u003e [\n\n    ],\n]);\n\n$rpl-\u003esetCreator(function () {\n    $obj = new \\stdClass();\n    $obj-\u003ename = 'test';\n\n    return $obj;\n})\n    -\u003esetDestroyer(function ($obj) {\n    echo \"call resource destroyer.\\n\";\n});\n\nvar_dump($rpl);\n\n$obj1 = $rpl-\u003eget();\n$obj2 = $rpl-\u003eget();\n$obj3 = $rpl-\u003eget();\n\nvar_dump($obj1, $obj2, $obj3,$rpl);\n\n$rpl-\u003eput($obj1);\n$rpl-\u003eput($obj2);\n\nvar_dump($rpl);\n\n$rpl-\u003ecall(function ($obj) {\n   echo \" $obj-\u003ename\\n\";\n});\n\nvar_dump($rpl);\n```\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-toolkit%2Fpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-toolkit%2Fpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-toolkit%2Fpool/lists"}