kodus/db-cache

PSR-16 cache-implementation for SQL databases

Maintainers

Package info

github.com/kodus/db-cache

pkg:composer/kodus/db-cache

Statistics

Installs: 27 264

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

2.1.0 2025-01-13 10:16 UTC

This package is auto-updated.

Last update: 2026-03-13 12:51:11 UTC


README

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

Installation

Install via Composer:

composer require kodus/db-cache

Usage

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.