An independent universal connection pool component.

Maintainers

👁 guanhui07

Package info

github.com/guanhui07/php-pool

pkg:composer/guanhui07/pool

Statistics

Installs: 36

Dependents: 1

Suggesters: 0

Stars: 1

v1.1.0 2023-02-03 12:27 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 7fd07930771870013e6e06738fb09118f6c4c993

  • raylin666 <1099013371.woop@qq.com>

redisphpmysqlpdopoolcoroutineswoole

This package is auto-updated.

Last update: 2026-06-05 16:59:49 UTC


README

👁 GitHub release
👁 PHP version
👁 GitHub license

环境要求

  • PHP >=7.2

安装说明

composer require "raylin666/pool"

使用方式

<?php

require 'vendor/autoload.php';

use Raylin666\Pool\SimplePool;
use Raylin666\Pool\PoolConfig;
use Raylin666\Pool\PoolOption;

$poolConfig = new PoolConfig(
 'database',
 function () {
 // 一般返回连接对象, 例如: return new PDO(...);
 return 'mysql';
 },
 (new PoolOption())
 ->withMinConnections(10)
 ->withMaxConnections(100)
 );

/**
 * 扩展提供了 SimplePool 和 SimpleConnection 类可以直接使用简单的连接池.
 * 也可以继承 Pool 和 Connection, 实现相对复杂的业务连接池
 */

$pool = new \Raylin666\Pool\SimplePool($poolConfig); // 创建连接池
$conn = $pool->get(); // 获取连接
$conn->getConnection(); // 获取连接内容, 即连接对象
$conn->release(); // 连接发布(放回连接池)
var_dump($pool);

欢迎阅读源码.

更新日志

请查看 CHANGELOG.md

联系

如果你在使用中遇到问题,请联系: 1099013371@qq.com. 博客: kaka 梦很美

License MIT