moridilion/doctrine-connection-keeper

一个用于保持 Doctrine DBAL 连接活跃的库

v1.0.0 2022-03-16 12:55 UTC

This package is auto-updated.

Last update: 2024-08-30 01:23:32 UTC


README

保持与您的 MySQL-Server 的连接活跃!

如果发生如 "MySQL 服务器已断开" 的错误,它将重试失败的语句。如果在最大重试次数后错误再次发生,则抛出错误。

配置示例

use \Mordilion\DoctrineConnectionKeeper\Doctrine\DBAL\Connection;

return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'wrapperClass' => Connection::class,
                'params' => [
                    'driver' => 'pdo_mysql',
                    'host' => 'localhost',
                    'port' => '3307',
                    'user' => '***',
                    'password' => '***',
                    'dbname' => '***',
                    'charset' => 'UTF8',
                    'connection_keeper' => [            // settings for the connection keeper
                        'reconnect_attempts' => 3,      // how often should it try to reconnect?
                        'refresh_on_exception' => true, // should it refresh the connection on an exception?            
                    ],
                ],
            ],
        ],
    ],
];