efureev/swoole-doctrine-dbal-pgsql-driver

Doctrine的Postgres Swoole 5数据库连接驱动

v2.0.1 2024-07-10 16:04 UTC

This package is auto-updated.

Last update: 2024-09-10 16:30:48 UTC


README

Doctrine DBAL为Swoole 5 Postgresql数据库连接提供的驱动程序

安装

通过composer安装此包是最简单的方法

$ composer require efureev/swoole-doctrine-dbal-pgsql-driver

示例

您可以使用提供的docker镜像测试功能,位于example文件夹中。CLI示例可以在example/cli.php中找到。HTTP服务器示例可以在example/server.php中找到

应用配置

doctrine:
  dbal:
    default_connection: 'swoole'
    connections:
      swoole:
        dbname: '%env(DB_MASTER_NAME)%'
        host: '%env(DB_MASTER_HOST)%'
        port: '%env(DB_MASTER_PORT)%'
        user: '%env(DB_MASTER_USER)%'
        password: '%env(DB_MASTER_PASS)%'
        driver_class: 'Swoole\Packages\Doctrine\DBAL\PgSQL\Driver'
        server_version: '15'
        options:
          poolSize: 3 # MAX count connections in one pool
          usedTimes: 3 # 1 connection (in pool) will be re-used maximum N queries
          connectionTTL: 60 # when connection not used this time(seconds) - it will be close (free)
          tickFrequency: 60000 # when need check possibilities downscale (close) opened connection to DB in pools
          connectionDelay: 2 # time(seconds) for waiting response from pool
          useConnectionPool: true # if false, will create new connect instead of using pool
          retryMaxAttempts: 2 # if connection in pool was timeout (before use) then try re-connect
          retryDelay: 1000 # delay to try fetch from pool again(milliseconds) if no connect available

将Bundle添加到bundles.php

[
    SwooleDoctrineDbalPoolBundle::class => ['all' => true],
]

就这些。