anonymous-php/longlife-pdo

Longlife connections for looped applications

1.1.1 2018-03-31 13:54 UTC

This package is auto-updated.

Last update: 2024-04-08 00:54:01 UTC


README

This library will be helpful in case you are working with connections in workers or under process managers like PHP-PM. It provides the easiest way to stop to think about connection life cycle in looped applications.

Longlife Pdo provides an extension to the Aura.Sql library along with a reconnection and prepared statements cache.

Installation

composer require anonymous-php/longlife-pdo

Usage

<?php

use \Anonymous\Longlife\LonglifePdo;

$pdo = new LonglifePdo('mysql:host=127.0.0.1;dbname=test', 'test', 'test');

// To check connection in 60 seconds after the last connection usage
$pdo->setCheckConnectionTimeout(60);

// To use prepared statements cache and limit it with 100 items
$pdo->setStatementsCacheLimit(100);

Dependencies

This packages is just an extension for the Aura.Sql so check it's requirements:

This package requires PHP 5.6 or later; it has also been tested on PHP 7 and HHVM. We recommend using the latest available version of PHP as a matter of principle.