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

ActiveLibrary[Caching](/categories/caching)

swaty/laravel-fallback-cache
============================

Allow Laravel cache connections to fallback to more stable drivers.

1.0.4(6mo ago)1913↓45.5%MITPHPPHP ^7.1.3 || ^8.0

Since Jan 29Pushed 6mo ago1 watchersCompare

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

READMEChangelog (1)Dependencies (11)Versions (5)Used By (0)

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

[](#laravel-cache-fallback)

[![GitHub license](https://camo.githubusercontent.com/3245b1f2bb1b4c250e9333c7575b2258d9d99e55e938f8a8a905ac1f8187edfa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73776174793030372f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/3245b1f2bb1b4c250e9333c7575b2258d9d99e55e938f8a8a905ac1f8187edfa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73776174793030372f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)[![Packagist Version](https://camo.githubusercontent.com/721ef0ff2c088849649348c8d1ac9aa82679a2ed727fb5dcad564864638980bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73776174792f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/721ef0ff2c088849649348c8d1ac9aa82679a2ed727fb5dcad564864638980bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73776174792f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)[![Packagist](https://camo.githubusercontent.com/3570035c3eaa985f632ae04ccf58ffbcfd915e85cc4e51a84dc874b8b86bccf5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73776174792f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/3570035c3eaa985f632ae04ccf58ffbcfd915e85cc4e51a84dc874b8b86bccf5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73776174792f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)[![GitHub issues](https://camo.githubusercontent.com/29877981694f4eb3b1e793cc32ee532319b24e11ce8bd81bcc9d6564c5f22004/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f73776174793030372f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/29877981694f4eb3b1e793cc32ee532319b24e11ce8bd81bcc9d6564c5f22004/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f73776174793030372f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)[![GitHub pull requests](https://camo.githubusercontent.com/fb229123b1b1f5b4142a3befcabae604fc90875fca3450652e9258bb4a1143db/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f73776174793030372f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/fb229123b1b1f5b4142a3befcabae604fc90875fca3450652e9258bb4a1143db/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f73776174793030372f6c61726176656c2d66616c6c6261636b2d63616368653f7374796c653d666c61742d737175617265)

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).

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

[](#prerequisites)

- PHP &gt;= 7.1.3
- Laravel/Lumen 9.x, 10.x, 11.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.**

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

[](#installation)

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

```
composer require swaty/laravel-fallback-cache
```

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/11.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(Swaty\CacheFallback\CacheServiceProvider::class);
```

Usage
-----

[](#usage)

The `fallback` key at the top level (next to default) specifies a fallback driver that will be used for all stores unless a store explicitly defines its own fallback.

```
