2 Star 4 Fork 0

makesurprise / laravel-routecache-middleware

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Laravel 5 Page Cache Use Middleware

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

  • flush -> Flush Current Request Url
  • flush:ref -> Flush Referer Url, Often used in AJAX
  • flush:url -> Flush Appoint Url, Often used in Manage And Clean Appoint Url, Add arg ?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!';
        });
    });

空文件

简介

laravel 5 页面缓存,路由中间键设定 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/surprise/laravel-routecache-middleware.git
git@gitee.com:surprise/laravel-routecache-middleware.git
surprise
laravel-routecache-middleware
laravel-routecache-middleware
master

搜索帮助