代码拉取完成,页面将自动刷新
Add page cache with route.
The cache is best not to write in the program logic inside, to find a cache is very tired, I suggest that the cache in the routing
缓存放在路由里面, 使用方法如下:
Route::group(['middleware' => 'cache:10'], function(){
Route::get('/', 'HomeController@index');
});
###Installation
Add to composer.json
"rose1988c/laravel-routecache-middleware":"dev-master"
or
composer require rose1988c/laravel-routecache-middleware:dev-master
Register the service provider by adding in the provider section in config/app.php
'providers' => [
...
Rose1988c\RouteCache\RouteCacheServiceProvider::class
...
Just in case
composer dump-autoload
Publish the migration and the config file
php artisan vendor:publish
Add to app\Http\Kernel.php
'cache' => \Rose1988c\RouteCache\CacheMiddleWare::class,
'flush' => \Rose1988c\RouteCache\FlushMiddleWare::class,
Setting Route.php
// set cache lifetime 10
Route::group(['middleware' => 'cache:10'], function(){
Route::get('/', 'DemoController@index');
});
Flush Cache
?flushurl=http://xxxxx
Route::group(['middleware' => 'flush'], function(){
Route::any('switchP', 'HomeController@switchP');
});
Route::group(['middleware' => 'flush:ref'], function(){
Route::any('switchP', 'HomeController@switchP');
});
// test url: http://192.168.141.129:8084/cleanCache?flushurl=http://192.168.141.129:8084/wealthbalance
// result : ok
Route::group(['middleware' => 'flush:url'], function(){
Route::any('cleanCache', function(){
echo 'hello, world!';
});
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型