PHPackages                             mathieu-bour/laravel-cache-fallback - 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. mathieu-bour/laravel-cache-fallback

AbandonedArchivedLibrary[Caching](/categories/caching)

mathieu-bour/laravel-cache-fallback
===================================

Allow Laravel cache connections to fallback to more stable drivers.

1.0.0(5y ago)1842.1k↓23.8%5[2 PRs](https://github.com/mathieu-bour/laravel-cache-fallback/pulls)MITPHPPHP ^7.1.3 || ^8.0

Since Dec 29Pushed 4y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (12)Versions (4)Used By (0)

Laravel Cache Fallback
======================

[](#laravel-cache-fallback)

[![GitHub license](https://camo.githubusercontent.com/df6632fa3b0a7a7f0e22348234d52fe02e4334b9d126d2891bb47afeef92f315/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/df6632fa3b0a7a7f0e22348234d52fe02e4334b9d126d2891bb47afeef92f315/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)[![Packagist Version](https://camo.githubusercontent.com/f331503e0c696e1b0785e3f54eb8c43afbc92e2234ca3a08a1469dfbdd4267c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/f331503e0c696e1b0785e3f54eb8c43afbc92e2234ca3a08a1469dfbdd4267c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)[![Packagist](https://camo.githubusercontent.com/9be55f3dd96c1a428bf0cd3f918406987dc0c93553dd70ed81ad78b9f4128deb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/9be55f3dd96c1a428bf0cd3f918406987dc0c93553dd70ed81ad78b9f4128deb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)[![GitHub issues](https://camo.githubusercontent.com/ef0e02252c7ba23a89fd89a4a74a85d3088dc7219c07ecf4cb8608472e5e9f08/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/ef0e02252c7ba23a89fd89a4a74a85d3088dc7219c07ecf4cb8608472e5e9f08/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)[![GitHub pull requests](https://camo.githubusercontent.com/e8002323847a66d3389cdddee7ff82534733fe36a1f9fb178a85230c9ada68f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e8002323847a66d3389cdddee7ff82534733fe36a1f9fb178a85230c9ada68f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)[![Codecov](https://camo.githubusercontent.com/4a1ec7f0b46e084001311f36d4ccfb065f372efbe5048e0cfdc8cb71186fa11c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4a1ec7f0b46e084001311f36d4ccfb065f372efbe5048e0cfdc8cb71186fa11c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)[![Scrutinizer code quality](https://camo.githubusercontent.com/0345a16a2afd8ad0aaa935c33e5a776f2d7327f1d49439f15c291a5b9fd6894e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/0345a16a2afd8ad0aaa935c33e5a776f2d7327f1d49439f15c291a5b9fd6894e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6d6174686965752d626f75722f6c61726176656c2d63616368652d66616c6c6261636b3f7374796c653d666c61742d737175617265)

Allow Laravel cache connections to fallback to more stable drivers.

This package is especially useful when you want your application to be **fault-tolerant**. For example, when using a Redis instance as cache store, you may want to be able to fallback to file store if the Redis instance is unavailable.

This package follows the [Semantic Versioning specification](https://semver.org).

Acknowledgements
----------------

[](#acknowledgements)

This package was inspired by [fingo/laravel-cache-fallback](https://github.com/fingo/laravel-cache-fallback), even if it is not maintained anymore.

Prerequisites
-------------

[](#prerequisites)

- PHP &gt;= 7.1.3
- Laravel/Lumen 5.8, 6.x, 7.x or 8.x

Supported cache methods
-----------------------

[](#supported-cache-methods)

This package support most of the cache methods (e.g. get, put, etc.). **The tagged cache is not supported at the moment.**

### Compatibility Matrix

[](#compatibility-matrix)

This package was tested against the following matrix:

Laravel/LumenPHP 7.1PHP 7.2PHP 7.3PHP 7.4PHP 8.05.8✔️✔️✔️✔️❌6.0❌✔️✔️✔️❌7.0❌✔️✔️✔️❌8.0❌❌✔️✔️✔️Installation
------------

[](#installation)

Simply add `mathieu-bour/laravel-cache-fallback` to your package dependencies.

```
composer require mathieu-bour/laravel-cache-fallback
```

This package does not publish any resource and its configuration directly handled in the `config/cache.php` file.

### Laravel

[](#laravel)

This package uses [Laravel Package Discovery](https://laravel.com/docs/7.x/packages#package-discovery), so you do need to do anything more. If you have disabled this feature, you can register the service provider in the `config/app.php`.

### Lumen

[](#lumen)

Register the service provider in the `bootstrap/app.php` file like so:

```
$app->register(Windy\CacheFallback\CacheFallbackServiceProvider::class);
```

Usage
-----

[](#usage)

Each cache store can now have a `fallback` key in its configuration. If during execution, the cache driver throws an exception, the fallback driver will be used instead.

```
