xtcat / laravel-redis-fallback by xtCat
forked from SpartnerNL/laravel-redis-fallback

Laravel 5 redis cache fallback to file
23,433
5
2
Package Data
Maintainer Username: xtCat
Maintainer Contact: davide.pedone@gmail.com (Davide Pedone)
Package Create Date: 2015-12-01
Package Last Update: 2018-02-02
Home Page: https://packagist.org/packages/davidepedone/laravel-redis-fallback
Language: PHP
License: MIT
Last Refreshed: 2024-03-28 03:07:22
Package Statistics
Total Downloads: 23,433
Monthly Downloads: 10
Daily Downloads: 0
Total Stars: 5
Total Watchers: 2
Total Forks: 3
Total Open Issues: 0

Redis cache fallback for Laravel 5

If you use Redis as cache driver on Laravel 5 and for some reason Redis server became unavailable, you will end up with a Connection Refused exception. This package simply checks for the connection and if test fails, cache is switched to file driver. As soon as Redis come back it will be used again.

How to use

Install LaravelRedisFallback as a Composer package, adding this line to your composer.json:

"xtcat/laravel-redis-fallback": "dev-master"

and update your vendor folder running the composer update command.

Replace the default cache service provider:

'providers' => array(
	...
	//'Illuminate\Cache\CacheServiceProvider',
	...
	\Xtcat\LaravelRedisFallback\LaravelRedisFallbackServiceProvider::class
	...
)

Events

You can listen to 'redis.unavailable' event in your listener, for example send an email to you when the redis server is down.

Enjoy!