PHPackages                             laravel-enso/cache-chain - 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. laravel-enso/cache-chain

ActiveLibrary[Caching](/categories/caching)

laravel-enso/cache-chain
========================

Cache chain for Laravel Enso

2.0.4(2mo ago)17.5k↑54.2%4MITPHPPHP ^8.0

Since Oct 7Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/laravel-enso/cache-chain)[ Packagist](https://packagist.org/packages/laravel-enso/cache-chain)[ Docs](https://github.com/laravel-enso/cache-chain)[ RSS](/packages/laravel-enso-cache-chain/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (23)Used By (0)

Cache Chain
===========

[](#cache-chain)

[![License](https://camo.githubusercontent.com/8cb2f84746dfaa54f8924fbfc96f16bf69ce762edecbd176e1eb6dfb2b3bd5fe/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f63616368652d636861696e2f6c6963656e7365)](LICENSE)[![Stable](https://camo.githubusercontent.com/f18e8452c8b16872593227a0ae2cae0749c0c525d7d72d293258318d0ba83043/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f63616368652d636861696e2f76657273696f6e)](https://packagist.org/packages/laravel-enso/cache-chain)[![Downloads](https://camo.githubusercontent.com/5f32a2524991c29959110550dc9b2f16dfb9f67c7489ee6f1a81eb3e3dc9ca7f/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f63616368652d636861696e2f646f776e6c6f616473)](https://packagist.org/packages/laravel-enso/cache-chain)[![PHP](https://camo.githubusercontent.com/ef6afd4ccdaa708a9b1a0a353d6d03a13ca1f03887b8db701d4118dc30a6735a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e302532422d3737376262342e737667)](composer.json)[![Issues](https://camo.githubusercontent.com/229d55a7adbc7b5f2cad8f86f1fa6f41f1edf16eb60b281418f02bf7467d7586/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f63616368652d636861696e2e737667)](https://github.com/laravel-enso/cache-chain/issues)[![Merge Requests](https://camo.githubusercontent.com/e16f8c7c5d87183ee7083035efb7e35b96fefcc79176e9ea0c8a9613b1bd724f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f63616368652d636861696e2e737667)](https://github.com/laravel-enso/cache-chain/pulls)

Description
-----------

[](#description)

Cache Chain is a layered Laravel cache store that lets multiple cache providers behave like a single repository.

It reads values from the first configured cache store that contains the key, then backfills the missing lower layers so subsequent reads can be served faster. Write operations are propagated to every configured provider, which makes the chain useful when combining fast local caches with slower persistent ones.

The package works independently of the Enso ecosystem and integrates through Laravel's native `Cache::store()` extension mechanism.

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

[](#installation)

Install the package:

```
composer require laravel-enso/cache-chain
```

The service provider is auto-registered and adds a `chain` cache driver to Laravel.

Configure a cache store that uses the driver:

```
'stores' => [
    'chain' => [
        'driver' => 'chain',
        'providers' => ['array', 'redis', 'file'],
        'defaultTTL' => 300,
    ],
],
```

`providers` must contain the cache stores that will participate in the chain, ordered from the fastest or most local layer to the slowest or most persistent one.

`defaultTTL` controls how values discovered in deeper layers are written back into missing upper layers. When it is omitted or set to `0`, backfilled values are cached forever.

Features
--------

[](#features)

- Registers a custom Laravel cache driver named `chain`.
- Supports combining multiple cache stores into one layered repository.
- Reads from the first provider that contains the requested key.
- Backfills missing lower layers when a value is found in a superior layer.
- Propagates `put`, `forever`, `forget`, `flush`, and `touch` operations to every configured provider.
- Keeps `increment()` and `decrement()` values in sync across all layers.
- Delegates cache locks to the last configured provider that supports Laravel locks.

Usage
-----

[](#usage)

Use the configured store like any other Laravel cache repository:

```
use Illuminate\Support\Facades\Cache;

$cache = Cache::store('chain');

$cache->put('settings.theme', 'dark', 300);

$theme = $cache->get('settings.theme');
```

Layered reads are automatic. If the first provider misses and a deeper provider contains the value, the package returns that value and repopulates the missing upper layers.

Increment and decrement operations keep all configured stores aligned:

```
$cache = Cache::store('chain');

$cache->put('visits', 10, 300);

$cache->increment('visits', 5);
```

::: warning Note `providers` cannot be empty.

If you want to use cache locks through the chain, at least one configured provider must support Laravel's lock API. :::

API
---

[](#api)

### Driver Registration

[](#driver-registration)

`LaravelEnso\CacheChain\AppServiceProvider`

The package registers a custom cache driver through `Cache::extend('chain', ...)`.

### Store Configuration

[](#store-configuration)

Required configuration keys for a chain store:

- `driver`
- `providers`

Optional configuration keys:

- `defaultTTL`

### Core Class

[](#core-class)

`LaravelEnso\CacheChain\Extensions\Chain`

Key methods:

- `providers(array $providers)`
- `get($key)`
- `put($key, $value, $seconds)`
- `touch($key, $seconds)`
- `increment($key, $value = 1)`
- `decrement($key, $value = 1)`
- `forever($key, $value)`
- `forget($key)`
- `flush()`
- `lock($name, $seconds = 0, $owner = null)`
- `restoreLock($name, $owner)`

### Exceptions

[](#exceptions)

`LaravelEnso\CacheChain\Exceptions\Chain`

Exception factories:

- `providers()`
- `lockProvider()`

Depends On
----------

[](#depends-on)

Framework dependency:

- [`laravel/framework`](https://github.com/laravel/framework) [↗](https://github.com/laravel/framework)

Contributions
-------------

[](#contributions)

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~141 days

Recently: every ~3 days

Total

15

Last Release

73d ago

Major Versions

1.5.0 → 2.0.02026-04-09

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

1.3.1PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (15 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (14 commits)")[![vmcvlad](https://avatars.githubusercontent.com/u/37445394?v=4)](https://github.com/vmcvlad "vmcvlad (6 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (3 commits)")[![GITmanuela](https://avatars.githubusercontent.com/u/44998004?v=4)](https://github.com/GITmanuela "GITmanuela (2 commits)")[![AbdullahiAbdulkabir](https://avatars.githubusercontent.com/u/33360580?v=4)](https://github.com/AbdullahiAbdulkabir "AbdullahiAbdulkabir (2 commits)")[![serpentblade](https://avatars.githubusercontent.com/u/1483665?v=4)](https://github.com/serpentblade "serpentblade (2 commits)")

---

Tags

cachelaravel-cachelaravel-ensocache-chain

### Embed Badge

![Health badge](/badges/laravel-enso-cache-chain/health.svg)

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

###  Alternatives

[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202583.7k8](/packages/swayok-alternative-laravel-cache)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[laravel-enso/rememberable

Model caching dependency for Laravel Enso

2864.9k43](/packages/laravel-enso-rememberable)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1420.4k](/packages/byerikas-cache-tags)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3417.0k](/packages/duncanmcclean-statamic-cargo)[salehhashemi/laravel-configurable-cache

Configurable Laravel cache manager

2115.2k2](/packages/salehhashemi-laravel-configurable-cache)

PHPackages © 2026

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