PHPackages                             kodus/db-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. kodus/db-cache

ActiveLibrary[Caching](/categories/caching)

kodus/db-cache
==============

PSR-16 cache-implementation for SQL databases

2.1.0(1y ago)027.6k↓26.3%1[1 issues](https://github.com/kodus/db-cache/issues)MITPHPPHP &gt;= 8.0

Since May 22Pushed 1y ago2 watchersCompare

[ Source](https://github.com/kodus/db-cache)[ Packagist](https://packagist.org/packages/kodus/db-cache)[ RSS](/packages/kodus-db-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

`kodus/db-cache`
================

[](#kodusdb-cache)

[PSR-16](https://www.php-fig.org/psr/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](https://camo.githubusercontent.com/487804500a039aee09e5d93e41b745b4cd68dcc0fdf801e67d26d30b93f83358/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e302532422d626c75652e737667)](https://packagist.org/packages/kodus/db-cache)[![Build Status](https://camo.githubusercontent.com/81eaa24d27de919c6ecf056c73d02a1bd865c78e9727dcebb89522471fc0aa50/68747470733a2f2f7472617669732d63692e6f72672f6b6f6475732f64622d63616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kodus/db-cache)[![Code Coverage](https://camo.githubusercontent.com/6ef7bc684c2179a7bde6e345499f068a535d5f6d41dfc57ac3fce83a542f0f13/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6475732f64622d63616368652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodus/db-cache/?branch=master)[![Code Quality](https://camo.githubusercontent.com/6f8df119744b5867124128c3b9ad67854aba719bed8e5a31f4e32d65fad6ecbb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f6475732f64622d63616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kodus/db-cache/?branch=master)

Installation
------------

[](#installation)

Install via [Composer](https://getcomposer.org/):

```
composer require kodus/db-cache

```

Usage
-----

[](#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](https://www.php-fig.org/psr/psr-16/) for general usage.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance41

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 70.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~687 days

Total

4

Last Release

490d ago

Major Versions

1.1.0 → 2.0.02022-08-24

PHP version history (2 changes)1.0.0PHP &gt;= 7.2

1.1.0PHP &gt;= 8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec1a54f85a6e46909df4ca4852ada0cc4b1482f7208dfc487d05554087e09cc9?d=identicon)[thomasnordahl-dk](/maintainers/thomasnordahl-dk)

![](https://www.gravatar.com/avatar/9d0432f9ee26cc6265bcf3817d88bf40a4a8669a603785b34946e9c15d7b3451?d=identicon)[boan-jfm](/maintainers/boan-jfm)

![](https://www.gravatar.com/avatar/22799a8c3c482e408f78fd86a999b271f1d5fd2e04b433c6d199f717b3032bb2?d=identicon)[JyskFynskeMedierJoej](/maintainers/JyskFynskeMedierJoej)

![](https://www.gravatar.com/avatar/a974d9ad4b2be14736394ce117f53f83e9186e9cc05002bc004678f0b0587e37?d=identicon)[mifich](/maintainers/mifich)

---

Top Contributors

[![JyskFynskeMedierJoej](https://avatars.githubusercontent.com/u/32329468?v=4)](https://github.com/JyskFynskeMedierJoej "JyskFynskeMedierJoej (31 commits)")[![mindplay-dk](https://avatars.githubusercontent.com/u/103348?v=4)](https://github.com/mindplay-dk "mindplay-dk (11 commits)")[![vortrixs](https://avatars.githubusercontent.com/u/15426116?v=4)](https://github.com/vortrixs "vortrixs (2 commits)")

---

Tags

cachemysqlphppostgresqlpsr-16

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kodus-db-cache/health.svg)

```
[![Health](https://phpackages.com/badges/kodus-db-cache/health.svg)](https://phpackages.com/packages/kodus-db-cache)
```

###  Alternatives

[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1076.9M130](/packages/laminas-laminas-cache)[cache/adapter-common

Common classes for PSR-6 adapters

11124.4M38](/packages/cache-adapter-common)[cache/filesystem-adapter

A PSR-6 cache implementation using filesystem. This implementation supports tags

705.8M82](/packages/cache-filesystem-adapter)[cache/array-adapter

A PSR-6 cache implementation using a php array. This implementation supports tags

548.3M151](/packages/cache-array-adapter)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

523.9M27](/packages/cache-redis-adapter)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

423.1M27](/packages/cache-simple-cache-bridge)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
