src/MysqlPool/MySQLPool.php
public static function recycle(MysqlProxy $conn, bool $busy = true)
    {
        self::go(function () use ($conn, $busy) {
            if (!self::$init) {
                throw new MySQLException('Should call MySQLPool::init.');
            }
            $id = spl_object_hash($conn);
            $connName = self::$connsNameMap[$id];
            if ($busy) {
                if (isset(self::$busyConns[$connName][$id])) {
                    unset(self::$busyConns[$connName][$id]);
                } else {
                    throw new MySQLException('Unknow MySQL connection.');
                }
            }
            $connsPool = &self::$spareConns[$connName];
            if (((count($connsPool) + self::$initConnCount[$connName]) >= self::$connsConfig[$connName]['maxSpareConns']) &&
                ((microtime(true) - self::$lastConnsTime[$id]) >= ((self::$connsConfig[$connName]['maxSpareExp']) ?? 0))
            ) {
                if ($conn->client->isConnected()) {
                    $conn->client->close();
                }
                unset(self::$connsNameMap[$id]);
            } else {
                if (!$conn->client->isConnected()) {
                    unset(self::$connsNameMap[$id]);
                    $conn = self::initConn($conn->server, $conn->serverFd, $connName);
                    $id = spl_object_hash($conn);
                }
                $connsPool[] = $conn;
                if (self::$pendingFetchCount[$connName] > 0) {
                    ++self::$resumeFetchCount[$connName];
                    self::$yieldChannel[$connName]->push($id);
                }
            }
        });
    }
public static function recycle(MysqlProxy $conn, bool $busy = true)
    {
        self::go(function () use ($conn, $busy) {
            if (!self::$init) {
                throw new MySQLException('Should call MySQLPool::init.');
            }
            $id = spl_object_hash($conn);
            $connName = self::$connsNameMap[$id];
            if ($busy) {
                if (isset(self::$busyConns[$connName][$id])) {
                    unset(self::$busyConns[$connName][$id]);
                } else {
                    throw new MySQLException('Unknow MySQL connection.');
                }
            }
            $connsPool = &self::$spareConns[$connName];
            if (((count($connsPool) + self::$initConnCount[$connName]) >= self::$connsConfig[$connName]['maxSpareConns']) &&
                ((microtime(true) - self::$lastConnsTime[$id]) >= ((self::$connsConfig[$connName]['maxSpareExp']) ?? 0))
            ) {
                if ($conn->client->isConnected()) {
                    $conn->client->close();
                }
                unset(self::$connsNameMap[$id]);
            } else {
                if (!$conn->client->isConnected()) {
                    unset(self::$connsNameMap[$id]);
                    $conn = self::initConn($conn->server, $conn->serverFd, $connName);
                    $id = spl_object_hash($conn);
                }
                $connsPool[] = $conn;
                if (self::$pendingFetchCount[$connName] > 0) {
                    ++self::$resumeFetchCount[$connName];
                    self::$yieldChannel[$connName]->push($id);
                }
            }
        });
    }
回收连接。

@param MysqlProxy $conn
@param bool       $busy