Connect Pool

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Connect Pool

Methods

Example

<?php
declare(strict_types=1);

use OpenSwoole\Core\Coroutine\Pool\ClientPool;
use OpenSwoole\Core\Coroutine\Client\PDOClientFactory;
use OpenSwoole\Core\Coroutine\Client\PDOConfig;

co::run(function() {
  $pool = new ClientPool(PDOClientFactory::class, new PDOConfig(), 8, true);

  $mysqlClient = $pool->get();
  $mysqlClient->query('SELECT SLEEP(10)')->fetch();

  $pool->put($mysqlClient);
});
Last updated on September 16, 2022