PSR-16 cache-implementation for SQL databases

2.0.0 2022-08-24 14:07 UTC

This package is auto-updated.

Last update: 2024-06-24 17:55:50 UTC



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.

PHP Version Build Status Code Coverage Code Quality


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.