定制 switon/pool 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

switon/pool

Composer 安装命令:

composer require switon/pool

包简介

Owner-scoped object pools with guard-based borrow and return for Switon Framework

README 文档

README

Pool CI PHP 8.3+

Switon's resource pool manager for pooling resources by owner and type, guard-based auto-return, and pool lifecycle events.

Highlights

  • Owner-scoped pools: each owner gets its own pool space.
  • Multiple pool types: one owner can keep separate variants such as default and readonly.
  • Scoped borrowing: PoolGuard returns resources automatically when it goes out of scope.
  • Capacity control: pool size, timeout, and busy conditions are handled explicitly.
  • Observable lifecycle: resource acquiring, returning, and busy states can be observed.

Installation

composer require switon/pool

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Pooling\PoolManagerInterface;

final class DatabaseClient
{
    public function query(string $sql): array
    {
        return [];
    }
}

final class ReportService
{
    #[Autowired] protected PoolManagerInterface $poolManager;

    public function __construct()
    {
        $this->poolManager->add($this, new DatabaseClient(), 4);
    }

    public function load(): array
    {
        $db = $this->poolManager->guard($this, timeout: 1.0);

        return $db->query('SELECT * FROM reports');
    }
}

Docs: https://docs.switon.dev/latest/pool

License

MIT.

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固