PSR-16 cache implementation for PostgreSQL (9.5+) and MySQL.
Tuned for fast, precise SQL - all operations (including multiple get/set/delete) are fully transactional and complete in a single round-trip.
No dependencies beyond the PSR-16 interface.
Install via Composer:
composer require kodus/db-cache
The constructor will automatically detect PostgreSQL or MySQL and use the appropriate adapter -
all you need to do is open a PDO
connection and specify a table-name and default TTL:
$pdo = new PDO("pgsql:host=localhost;port=5432;dbname=test", "root", "root");
$cache = new DatabaseCache($pdo, "my_cache_table", 24*60*60);
Tables are automatically created with the first database operation.
Please refer to PSR-16 documentation for general usage.