PHP code example of shado / php-resource-pool
1. Go to this page and download the library: Download shado/php-resource-pool library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shado / php-resource-pool example snippets
$factory = function (\Shado\ResourcePool\FactoryController $controller) {
$newConnection = new DbConnection();
$newConnection->onClose($controller->detach(...)); // When connection closes, detach it from the pool
return $newConnection;
};
$pool = new \Shado\ResourcePool\ResourcePool($factory, 10);
$connection = $pool->borrow(); // `$connection` is ready to use :)
// $connection->query(...);
$pool->return($connection);