kodus / db-cache
PSR-16 cache-implementation for SQL databases
Installs: 2 302
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 0
Open Issues: 1
Requires
- php: >= 7.2
- ext-pdo: *
- psr/simple-cache: ^1
Requires (Dev)
- mindplay/simple-cache: ^1.0
- phpunit/phpunit: ^8.1.5
Provides
This package is auto-updated.
Last update: 2020-12-29 14:50:49 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.