GeneaLabs / laravel-model-caching没有通过急切加载来缓存我的雄辩查询

I came across this library and trying to use it in a project of mine.

Firstly, I've added the following line to my .env:


I am using file cache store to test, in production I will use redis.

Then I've created app/CacheableModel.php with the following:


namespace App;

use Illuminate\Database\Eloquent\Model;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;

abstract class CacheableModel extends Model
    use Cachable;

and then I've updated all my models (except for app/User.php) like this example:


namespace App;

class Company extends CacheableModel

and I tested it using a test route like this:

Route::get('test', function() {

    $testUser = \App\User::where('email', '')
        ->with('company.users', 'company.subscription')



When I visit test route, I can see the data loaded and dumped. If I refresh the page, it doesn't seem to be caching to be caching the above query.

I verified that it's not caching my eloquent queries by looking at the query log (using laravel telescope) as well as looking at storage/framework/cache/data - it's empty.

Any ideas what might be wrong?

Is this not caching because app/User.php model doesn't use the CacheableModel base class and the test query starts from the user model?

duanbarong4321 请尝试使用除用户型号以外的其他型号。希望它能奏效!
一年多之前 回复
dongliang1865 我觉得你用过Cachable;没有雄辩的缓存。尝试使用中的演示代码,然后进行测试。也许你发现了什么问题!另外,请从以下文档中读取以下内容:例外:用户模型
一年多之前 回复
Csdn user default icon