PHPackages                             hms5232/laravel-twin-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. hms5232/laravel-twin-cache

AbandonedArchivedLibrary[Caching](/categories/caching)

hms5232/laravel-twin-cache
==========================

Use second cache flexibly in Laravel.

v0.1.2(3y ago)0812[1 issues](https://github.com/hms5232/laravel-twin-cache/issues)MITPHPPHP ^7.3 || ^8.0

Since Aug 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hms5232/laravel-twin-cache)[ Packagist](https://packagist.org/packages/hms5232/laravel-twin-cache)[ RSS](/packages/hms5232-laravel-twin-cache/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (5)Versions (6)Used By (0)

laravel-twin-cache
==================

[](#laravel-twin-cache)

[![](https://camo.githubusercontent.com/30445d77281c24b7fe3ed876a6b1cfc4f6dc38c08a9484095a979ea738cc3f95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f686d73353233322f6c61726176656c2d7477696e2d6361636865)](https://camo.githubusercontent.com/30445d77281c24b7fe3ed876a6b1cfc4f6dc38c08a9484095a979ea738cc3f95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f686d73353233322f6c61726176656c2d7477696e2d6361636865)[![](https://camo.githubusercontent.com/4123a6ba3babcb7cd292b8c9487d09ce27230bcf56c8cfeade52a2ade4d6eecd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686d73353233322f6c61726176656c2d7477696e2d6361636865)](https://packagist.org/packages/hms5232/laravel-twin-cache)[![](https://camo.githubusercontent.com/b703176de0ee6f4bbed2ae380dd8d5446c90569258fe6209bb7a2c24b825031a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f686d73353233322f6c61726176656c2d7477696e2d6361636865)](https://packagist.org/packages/hms5232/laravel-twin-cache)[![](https://camo.githubusercontent.com/ecd845e4e35b3808bcc1442a71ad897b04ace708bd45025e686c7d6de5a4fcb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686d73353233322f6c61726176656c2d7477696e2d6361636865)](LICENSE)

[![](https://camo.githubusercontent.com/b055cadeeae123422a712b9861df978c4e289b26629f5ae3e531493b909de764/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f686d73353233322f6c61726176656c2d7477696e2d63616368652f6c61726176656c2d382e796d6c3f6272616e63683d6d61696e266c6162656c3d4c61726176656c25323038)](https://github.com/hms5232/laravel-twin-cache/actions/workflows/laravel-8.yml?query=branch%3Amain)

Use second cache flexibly in Laravel.

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

[](#installation)

```
composer require hms5232/laravel-twin-cache

```

Usage
-----

[](#usage)

### config

[](#config)

Add `twin` store in `config/cache.php`:

```
'stores' => [
    // other store config here

    'twin' => [
        'driver' => 'twin',
        'older' => env('TWIN_CACHE_OLDER', 'redis'),  // First/preferred cache
        'younger' => env('TWIN_CACHE_YOUNGER', 'database'),  // Second/backup cache
        'sync_ttl' => env('TWIN_CACHE_TTL'),  // TTL for younger synced to older. Default is null => forever
    ],
],
```

Change cache drive in `.env`:

```
CACHE_DRIVER=twin

```

### method

[](#method)

All Laravel built-in methods modify the `older` cache, and you can add suffix `Twin` to method name for twin cache.

For example, you want to update both older and younger cache:

```
Cache::put('foo', 'bar');
// change "put" to "putTwin"
Cache::putTwin('foo', 'bar');
```

Another example, a key is in younger cache drive but doesn't exist in older. You want to sync this key when select this key:

```
// only select older cache
Cache::get('foo');

// This will select older cache first
// If no result, select younger, else return result
// 1. If exists in younger, insert into older cache and return
// 2. If it doesn't exist, return default value
Cache::getTwin('foo', 'bar');
```

So you can use second cache flexibly depend on need.

#### Method List

[](#method-list)

All parameters are same.

Laravel built-intwin cache`get``getTwin``many``put``putTwin``putMany``putManyTwin``increment``incrementTwin``descrement``descrementTwin``forever``foreverTwin``forget``forgetTwin``flush``flushTwin``has``hasTwin`LICENSE
-------

[](#license)

Copyright (c) 2022 hms5232

See [LICENSE](LICENSE).

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Total

3

Last Release

1405d ago

### Community

Maintainers

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

---

Top Contributors

[![hms5232](https://avatars.githubusercontent.com/u/43672033?v=4)](https://github.com/hms5232 "hms5232 (23 commits)")

---

Tags

laravel-cachelaravel-package

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/hms5232-laravel-twin-cache/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M302](/packages/laravel-horizon)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[illuminate/cache

The Illuminate Cache package.

12937.0M1.8k](/packages/illuminate-cache)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M193](/packages/laravel-ai)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)

PHPackages © 2026

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