PHPackages                             jardisadapter/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. [Database &amp; ORM](/categories/database)
4. /
5. jardisadapter/cache

ActiveLibrary[Database &amp; ORM](/categories/database)

jardisadapter/cache
===================

PSR-16 multi-layer caching engine with write-through propagation across Redis, APCu, Database, and Memory

v1.0.0(2mo ago)0621proprietaryPHPPHP &gt;=8.2CI passing

Since Mar 18Pushed 2mo agoCompare

[ Source](https://github.com/jardisAdapter/cache)[ Packagist](https://packagist.org/packages/jardisadapter/cache)[ Docs](https://github.com/jardisAdapter/cache)[ RSS](/packages/jardisadapter-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (6)Used By (1)

Jardis Cache
============

[](#jardis-cache)

[![Build Status](https://github.com/jardisAdapter/cache/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisAdapter/cache/actions/workflows/ci.yml/badge.svg)[![License: PolyForm Shield](https://camo.githubusercontent.com/d8fb46c82be4c5312bf3e372ac734dfdf6a8b328e9c2b2856af671adbb0600a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d506f6c79466f726d253230536869656c642d626c75652e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/c51bda247654363d3e30bc352674dd761a9557803a14af0226eb411d6dc0006b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d627269676874677265656e2e737667)](phpstan.neon)[![PSR-12](https://camo.githubusercontent.com/34b10db0caa29bacd49bda5c437a8de95385f036f3230b31fa605326e18da22c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5053522d2d31322d626c75652e737667)](phpcs.xml)[![PSR-16](https://camo.githubusercontent.com/0bb4bb647f0531ef86892e4c14d03f9c6541df67b97e14817590ed6ec021c549/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43616368652d5053522d2d31362d627269676874677265656e2e737667)](https://www.php-fig.org/psr/psr-16/)[![Coverage](https://camo.githubusercontent.com/3a266947b2f6d6a62718755c3e2abc9ec8d4c0659aaf572884b81e9b93f9fed4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f7665726167652d38342e35312532352d677265656e2e737667)](https://github.com/jardisAdapter/cache)

> Part of the **[Jardis Business Platform](https://jardis.io)** — Enterprise-grade PHP components for Domain-Driven Design

PSR-16 multi-layer caching engine. Chain Memory, APCu, Redis, and Database backends in a single `Cache` instance. On a cache miss in a fast layer, the value is automatically backfilled from the next slower layer — so subsequent reads hit the fastest backend available. Writes propagate to all configured layers simultaneously.

---

Features
--------

[](#features)

- **Multi-Layer Chain** — Stack any number of backends; reads backfill upper layers automatically
- **5 Backends** — `CacheMemory`, `CacheApcu`, `CacheRedis`, `CacheDatabase`, `CacheNull`
- **PSR-16** — Full `Psr\SimpleCache\CacheInterface` implementation on every layer
- **Namespace Isolation** — Each layer instance carries its own namespace prefix
- **Immutable After Construction** — All layers set via constructor; no mutation at runtime
- **Null Object Pattern** — Empty `Cache([])` degrades gracefully to a no-op `CacheNull`
- **TTL Support** — Integer seconds or `DateInterval` on every `set()` / `setMultiple()`
- **Zero Dependencies** — No third-party packages required beyond PSR interfaces

---

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

[](#installation)

```
composer require jardisadapter/cache
```

Quick Start
-----------

[](#quick-start)

```
use JardisAdapter\Cache\Cache;
use JardisAdapter\Cache\Adapter\CacheMemory;
use JardisAdapter\Cache\Adapter\CacheRedis;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

// Two-layer cache: L1 = in-process memory, L2 = Redis
$cache = new Cache([
    new CacheMemory('myapp'),
    new CacheRedis($redis, 'myapp'),
]);

$cache->set('user:42', $userData, ttl: 300);
$user = $cache->get('user:42');
```

Advanced Usage
--------------

[](#advanced-usage)

```
use JardisAdapter\Cache\Cache;
use JardisAdapter\Cache\Adapter\CacheMemory;
use JardisAdapter\Cache\Adapter\CacheApcu;
use JardisAdapter\Cache\Adapter\CacheRedis;
use JardisAdapter\Cache\Adapter\CacheDatabase;

// Four-layer cascade: L1 memory → L2 APCu → L3 Redis → L4 database
// A miss at L1 checks L2, then L3, then L4.
// When found, the value is written back into all faster layers automatically.
$cache = new Cache([
    new CacheMemory('orders'),
    new CacheApcu('orders'),
    new CacheRedis($redis, 'orders'),
    new CacheDatabase($pdo, namespace: 'orders'),
]);

// Bulk operations — all layers updated in one call
$cache->setMultiple([
    'order:101' => $order101,
    'order:102' => $order102,
], ttl: 600);

$orders = $cache->getMultiple(['order:101', 'order:102']);

// Invalidate a key across all layers
$cache->delete('order:101');

// Expire stale database entries explicitly
$dbLayer = new CacheDatabase($pdo, namespace: 'orders');
$dbLayer->cleanExpired();
```

Documentation
-------------

[](#documentation)

Full documentation, guides, and API reference:

**[jardis.io/docs/adapter/cache](https://jardis.io/docs/adapter/cache)**

License
-------

[](#license)

This package is licensed under the [PolyForm Shield License 1.0.0](LICENSE.md). Free for all use except building competing frameworks or developer tooling.

---

**[Jardis](https://jardis.io)** · [Documentation](https://jardis.io/docs) · [Headgent](https://headgent.com)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance88

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~20 days

Total

2

Last Release

62d ago

### Community

Maintainers

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

---

Top Contributors

[![Headgent](https://avatars.githubusercontent.com/u/245725954?v=4)](https://github.com/Headgent "Headgent (1 commits)")

---

Tags

databaserediscachefilememoryDomain Driven DesignHeadgentjardis

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpfastcache/phpfastcache

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[desarrolla2/cache

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

1322.5M47](/packages/desarrolla2-cache)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[fire015/flintstone

A key/value database store using flat files for PHP

285108.7k7](/packages/fire015-flintstone)[vectorial1024/laravel-cache-evict

Efficiently remove expired Laravel file/database cache data

5813.2k](/packages/vectorial1024-laravel-cache-evict)

PHPackages © 2026

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