mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.24k stars 214 forks source link

I can't see cache on redis #355

Closed reasecret closed 4 years ago

reasecret commented 4 years ago

Issue

I think I've configured correctly package settings: My .env file:

CACHE_DRIVER=redis
MODEL_CACHE_STORE=redis2

My cache config:

         'redis2' => [
             'driver' => 'redis',
             'connection' => 'model-cache',
         ],

My database config:

        'default' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB', '0'),
        ],

        'cache' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_CACHE_DB', '1'),
        ],

        'model-cache' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB', '2'),
        ],

Environment

Laravel Version: 7.13 Laravel Model Caching Package Version: 0.8.6 PHP Version: 7.3.18 Operating System & Version: Windows 10

I'm opening http://localhost/redis, redis page is opening but there is no cache. However cache is working, I'm checking query counts with Laravel debugbar. Am I doing something wrong?

mikebronner commented 4 years ago

@reasecret Honestly, I have never accessed the redis cache via a URL. I use TablePlus to connect. Can you point me to the documentation that shows it can be viewed via URL?

reasecret commented 4 years ago

I'm using Laragon (Redis included). http://localhost/redis page looks like this (No cache):

https://pasteboard.co/Jck9OEz.png

My another project on localhost, http://localhost/redis page looks like this (Cached data is here):

https://pasteboard.co/Jckcuso.png

reasecret commented 4 years ago

Ok now I think issue solved.

I removed MODEL_CACHE_STORE=redis2 from my .env file and used default redis connection. Looks like its working now.

mikebronner commented 4 years ago

Sounds good, yea I don't use Laragon, I use Homestead. I'll close this issue for now, as it seems that you are good to go.