Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?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);
});