codercms / laravel-pg-conn-pool
Laravel PostgreSQL connection pool
v1.0.2
2020-09-10 17:18 UTC
Requires
- php: ^7.4
- ext-pdo: *
- ext-swoole: *
- illuminate/database: ^6.0
- makise-co/postgres: ^2.0
Requires (Dev)
- laravel/framework: ^6.0
- orchestra/testbench: ^4.5
- swoole/ide-helper: ^4.4
This package is auto-updated.
Last update: 2025-03-11 04:09:59 UTC
README
Laravel PostgreSQL connection pool
WARNING: The package is not production-ready yet (only for testing purposes).
Reasons:
- Gaining more performance to the application
Requirements:
- PHP 7.4
- Laravel 6.x
- Swoole 4.x and higher
- ext-pq
Usage
Configuration (config/database.php
):
'pgsql_pool' => [
// driver name that supports connection pooling
'driver' => 'pgsql_pool',
// how much connections is needed
'max_active' => 4,
// minimum number of active connections
'min_active' => 2,
// how much time to wait for an avaiable connection
'max_wait_time' => 5.0, // 5 seconds
// automatically close connections which are idle more than a minute
'max_idle_time' => 60,
// how often to check idle connections
'validation_interval' => 30.0, // every 30 seconds
// for more paremeters read the - https://github.com/makise-co/pool
// parameter names in the connection config should be in snake_case
// default postgres driver config directives below
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
Notes
- The following methods on LazyConnection may not work (because they rely on the real connection):
- setPdo
- setReadPdo
- disconnect
- reconnect
- All connections management is performed by connection pool, not by Laravel
- Each coroutine can take only one connection from the pool