Git Product home page Git Product logo

laravel-cache-response's Introduction

klinson/laravel-cache-response

Packagist License

描述/Description

Laravel请求结果自动缓存中间件,缓存返回数据,适用于接口返回json或其他格式数据

依赖缓存,缓存驱动必须是redismemcached

安装/Installation

安装包/Install Package

composer require klinson/laravel-cache-response

配置/Configuration

  • Laravel >= 5.5+, laravel支持 Package Discovery, 可直接使用

  • laravel < 5.5, 需要在config/app.phpproviders数组中加入下面一条

    Klinson\CacheResponse\CacheResponseServiceProvider::class,

    需要在config/app.phpaliases数组中加入下面一条

    'CacheResponse' => Klinson\CacheResponse\CacheResponse::class,

发布配置/Publish Configuration

php artisan vendor:publish --provider="Klinson\CacheResponse\CacheResponseServiceProvider"

使用/Usage

可以在路由中指定使用cache_response中间件,也可以在全局配置中进行加入中间件

Route::get('data', 'DataController@all')->middleware('cache_response');

助手函数cache_response()

// 获取CacheResponse对象
cache_response()

// 获取$cache_key下的缓存返回Response对象
cache_response($cache_key)

// 获取$request下的缓存返回Response对象
cache_response($request)

// 设置缓存
cache_response($request, $response)

清除所有缓存/Clear All Cache

仅在缓存驱动是redismemcached有效

php artisan cache-response:clear

laravel-cache-response's People

Contributors

klinson avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Forkers

yijiangwen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.