mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-03 20:27:59 +08:00
Upgrade pool
This commit is contained in:
parent
1456cec10a
commit
222889bf51
11
zh/pool.md
11
zh/pool.md
@ -39,6 +39,8 @@ class MyConnectionPool extends Pool
|
|||||||
这里框架提供了一个非常简单的连接池实现。
|
这里框架提供了一个非常简单的连接池实现。
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
use Hyperf\Pool\SimplePool\PoolFactory;
|
use Hyperf\Pool\SimplePool\PoolFactory;
|
||||||
use Swoole\Coroutine\Http\Client;
|
use Swoole\Coroutine\Http\Client;
|
||||||
|
|
||||||
@ -46,9 +48,16 @@ $factory = $container->get(PoolFactory::class);
|
|||||||
|
|
||||||
$pool = $factory->get('your pool name', function () use ($host, $port, $ssl) {
|
$pool = $factory->get('your pool name', function () use ($host, $port, $ssl) {
|
||||||
return new Client($host, $port, $ssl);
|
return new Client($host, $port, $ssl);
|
||||||
}, $this->option);
|
}, [
|
||||||
|
'max_connections' => 50
|
||||||
|
]);
|
||||||
|
|
||||||
$connection = $pool->get();
|
$connection = $pool->get();
|
||||||
|
|
||||||
$client = $connection->getConnection(); // 即上述 Client.
|
$client = $connection->getConnection(); // 即上述 Client.
|
||||||
|
|
||||||
|
// Do somethind.
|
||||||
|
|
||||||
|
$connection->release();
|
||||||
|
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user