pdeio / redis-driver-fallback
当Redis服务器停止时,第二个缓存驱动程序开始工作。当Redis服务器恢复或第二个缓存驱动程序启动时,Laravel的缓存可以随时清除。这样,缓存系统保持同步,不会出现加载旧缓存注册的问题。
v1.0.0
2019-04-05 22:16 UTC
Requires
- guzzlehttp/guzzle: 6.*
This package is auto-updated.
Last update: 2024-09-06 10:34:26 UTC
README
当Redis服务器停止时,第二个缓存驱动程序开始工作。当Redis服务器恢复或第二个缓存驱动程序启动时,Laravel的缓存可以随时清除。这样,缓存系统保持同步,不会出现加载旧缓存注册的问题。
内容
安装
- 为了安装Redis Drive Fallback,只需运行
composer require pdeio/redis-driver-fallback
- [可选] 创建配置文件(config/redis-driver-fallback.php),运行
php artisan vendor:publish --provider="Pdeio\RedisDriverFallback\RedisDriverServiceProvider"
配置
在config/redis-driver-fallback.php
中设置属性值。
/*
|--------------------------------------------------------------------------
| Fallback ON / OFF
|--------------------------------------------------------------------------
|
|
| Enable / disable the redis driver fallback to test if it is working.
|
| The Redis driver fallback only works if the selected cache driver is set to redis,
| otherwise even if this option is set to on, only the default laravel cache manager
| will works.
|
*/
'fallback_turn_on' => true,
/*
|--------------------------------------------------------------------------
| Cache Driver Fallback
|--------------------------------------------------------------------------
|
| This option controls the fallback cachedriver that temporarily replaces the redis cache.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "dynamodb"
|
*/
'fallback_driver' => 'file',
/*
|--------------------------------------------------------------------------
| Synchronization mode
|--------------------------------------------------------------------------
|
| Here it is possible to define the synchronization mode: when the redis server stops,
| cache of the new driver selected is cleared in order to remain updated.
| When the redis returns, the redis cache is cleared before running again.
| This way, you don't run the risk of downloading not updated data from the cache.
|
| Set true, to activate the synchronization mode.
*/
'sync_mode' => false,
/*
|--------------------------------------------------------------------------
| Alert email
|--------------------------------------------------------------------------
|
| You have the option to send yourself an email with a default text,
| whenever the redis server should fall.
|
| In case of problems with the mail service, it is possible to catch the error
| without interrupting the entire cache request. Set "catch_error" to true, so a
| log error will be saved in "app/storage/app/redis/mails_error.log" with more
| details. If you set this option to false, laravel will force to send e-mails
| and an error exception will interrupt the request with an error exception page.
| It is recommended to leave this option on false, in development mode.
|
| You can edit the email template, if you want.
| In the folder "views/pdeio/redis-driver-fallback-email-template/alert.blade.php".
| If you delete this folder, the application does not crash, but cannot be sent
| any email from this package. You can use the redis event that is triggered when
| the redis server stops.
|
| It is recomended that you use the event ('redis.unvailable') which is fired
| whenever the redis stops working, to send the email through your controller
| and using your laravel queues.
*/
'email_config' => [
'send_email' => false,
'to' => 'email@email.com',
'catch_error' => false,
]
许可证
Redis Driver Fallback是免费软件,根据MIT许可证条款分发。