kodus / db-cache
PSR-16 cache-implementation for SQL databases
Installs: 17 258
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 1
Requires
- php: >= 8.0
- ext-pdo: *
- psr/simple-cache: ^2||^3
Requires (Dev)
- phpunit/phpunit: ^9.5
Provides
This package is auto-updated.
Last update: 2024-10-24 18:44:22 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.
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.