PHPackages                             klinson/laravel-cache-response - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. klinson/laravel-cache-response

Active1[Caching](/categories/caching)

klinson/laravel-cache-response
==============================

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

v1.2.1(6y ago)2121MITPHPPHP &gt;=5.6

Since Jul 25Pushed 6y agoCompare

[ Source](https://github.com/klinson/laravel-cache-response)[ Packagist](https://packagist.org/packages/klinson/laravel-cache-response)[ Docs](https://github.com/klinson/laravel-cache-response)[ RSS](/packages/klinson-laravel-cache-response/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (5)Used By (0)

klinson/laravel-cache-response
==============================

[](#klinsonlaravel-cache-response)

[![Packagist License](https://camo.githubusercontent.com/b5924d4b515082b8e54cd79c8ac6f34a2cd87907b0c3e593dd80839d7cb39380/68747470733a2f2f706f7365722e707567782e6f72672f62617272797664682f6c61726176656c2d64656275676261722f6c6963656e73652e706e67)](http://choosealicense.com/licenses/mit/)

描述/Description
--------------

[](#描述description)

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

> 依赖缓存，缓存驱动必须是`redis`、`memcached`

安装/Installation
---------------

[](#安装installation)

### 安装包/Install Package

[](#安装包install-package)

```
composer require klinson/laravel-cache-response
```

### 配置/Configuration

[](#配置configuration)

- Laravel &gt;= 5.5+, laravel支持 [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery), 可直接使用
- laravel &lt; 5.5, 需要在`config/app.php`中`providers`数组中加入下面一条

    ```
    Klinson\CacheResponse\CacheResponseServiceProvider::class,
    ```

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

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

### 发布配置/Publish Configuration

[](#发布配置publish-configuration)

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

使用/Usage
--------

[](#使用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
----------------------

[](#清除所有缓存clear-all-cache)

> 仅在缓存驱动是`redis`、`memcached`有效

```
php artisan cache-response:clear
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

4

Last Release

2459d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21521d5b326bd671edafea5b4379a8f2802e9f8af64bff295868c389b12c01f1?d=identicon)[klinson](/maintainers/klinson)

---

Top Contributors

[![klinson](https://avatars.githubusercontent.com/u/41332835?v=4)](https://github.com/klinson "klinson (9 commits)")

---

Tags

responsemiddlewarelaravelcacheautoklinson

### Embed Badge

![Health badge](/badges/klinson-laravel-cache-response/health.svg)

```
[![Health](https://phpackages.com/badges/klinson-laravel-cache-response/health.svg)](https://phpackages.com/packages/klinson-laravel-cache-response)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[flc/laravel-middleware-cache-response

Laravel中间件-Response缓存

608.2k](/packages/flc-laravel-middleware-cache-response)[arifhp86/laravel-clear-expired-cache-file

Remove laravel expired cache file/folder

36128.7k](/packages/arifhp86-laravel-clear-expired-cache-file)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
