Connect Pool

Latest version: pecl install openswoole-22.0.0 | composer require openswoole/core:22.1.1

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