mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.26k stars 217 forks source link

Error ReflectionException (-1) Class redis does not exist #210

Closed phongtnit closed 5 years ago

phongtnit commented 5 years ago

Describe the bug There is a error when I use the package. I install redis and laravel-model-caching package via

composer require predis/predis
composer require genealabs/laravel-model-caching

I also sets MODEL_CACHE_STORE=redis in .env file. After that, I used the GeneaLabs\LaravelModelCaching\Traits\Cachable in my existing model.

When I tried the access my controller, the above error happens. What I should to do to fix it?

Bug image

Eloquent Query Please provide the complete eloquent query that caused the bug, for example:

Keywords::select(
            'id', 'name', 
        )
            ->orderBy('id', 'DESC')
            ->with(['parent' => function ($q) {
                $q->select('id', 'name');
            }])
            ->paginate(10);

Environment

mikebronner commented 5 years ago

Hi @phongtnit, I have not seen that problem. Have you followed the Predis instructions here (https://laravel.com/docs/5.7/redis) ? It sounds like Predis is not installed correctly, or at least not recognized by Laravel.

nguyentranchung commented 5 years ago

Hi @phongtnit Your cache driver is redis, not predis. See here

https://github.com/laravel/laravel/blob/4997f08105d6fb941b1ed2c749ebd2f55fba5a74/config/cache.php#L75

mikebronner commented 5 years ago

Closing this due to inactivity. Please open a new issue with complete stack trace and other relevant information if it occurs again. Thanks :)