Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lada-cache:flush generates Redis-Cluster error - cannot use "KEYS" #62

Open
madsem opened this issue Apr 19, 2018 · 12 comments
Open

lada-cache:flush generates Redis-Cluster error - cannot use "KEYS" #62

madsem opened this issue Apr 19, 2018 · 12 comments

Comments

@madsem
Copy link

madsem commented Apr 19, 2018

Laravel: v5.6.16

Trying to run lada-cache:flush before a new migration (and also trying to run the db:seed command)
generates a redis error:

panel.vm $ php artisan lada-cache:flush

   Predis\NotSupportedException  : Cannot use 'KEYS' with redis-cluster.

This is my database.php config:

'redis' => [

        'client' => 'predis',

        'options' => [
            'cluster' => 'redis',
        ],

        'clusters' => [
            'default' => [
                'host' => env('REDIS_HOST', 'localhost'),
                'password' => env('REDIS_PASSWORD', null),
                'port' => env('REDIS_PORT', 6379),
                'database' => 0,
            ],
        ],

    ],
@spiritix
Copy link
Owner

Didn't test the flush command so far with a cluster, to be honest. Predis does currently not support several commands for cluster environments, will need to develop a workaround for this.

Are you actually using a cluster?

@madsem
Copy link
Author

madsem commented Apr 19, 2018

yeah using a cluster in production on AWS Elasticache. A workaround is to change the config locally to default when running a migration, but that just introduces problems because I can't be sure if it will work the same way in production I guess.

@spiritix
Copy link
Owner

Well, what you always can do is flushing the entire Redis DB on production instead of just Lada Cache. That will certainly work if your application doesn't depend on any data in Redis being persistent.

@madsem
Copy link
Author

madsem commented Apr 19, 2018

Ok true, or I switch to cluster mode disabled. Luckily I am flexible there.
Laravel itself also has issues with Cache::tags() & cluster mode enabled.

@spiritix spiritix added the bug label Apr 20, 2018
@madsem
Copy link
Author

madsem commented Apr 21, 2018

This is the fix suggested by someone in the Laravel repo for using flush with cache tags, it might also solve this issue here as I saw Lada cache also isn't using curly braces:
https://github.com/laravel/framework/pull/17792/files

laravel/framework#17792 (comment)

@spiritix
Copy link
Owner

I am not sure if that's going to work, according to the author of Predis one would need to iterate over all connections: predis/predis#338 (comment)

It appears a bit strange to me why this should be required since for all other commands iterating is not required, but ok, either this or your proposed solution should work for sure.

@madsem
Copy link
Author

madsem commented Apr 23, 2018

Can't say anything about the connection looping, I tested the curly brace solution with Laravel 5.6 and there it seemed to fix the issue indeed, after implementation the errors about 'Cannot use 'DEL' with redis-cluster.' in combination with Cache::tags() were gone.

@xwiz
Copy link
Contributor

xwiz commented May 27, 2020

@spiritix What's the state of this issue currently?

@spiritix
Copy link
Owner

@xwiz I currently only have capacity to fix major bugs in my open source projects. Contributions are very welcome.

@xwiz
Copy link
Contributor

xwiz commented May 28, 2020

Thanks @spiritix

Looks like that will happens as I'm running into some issues. Good to know you're open to contributions.

@xwiz
Copy link
Contributor

xwiz commented May 28, 2020

I think for contributors it would be great to have documented the current conditions that trigger the flush cache automatically. By default I assume that would be created, updated, and deleted but one needs to delve into the code to confirm.

@spiritix
Copy link
Owner

spiritix commented Jun 2, 2020

So the flush command is never triggered automatically. It's only for debug and maintenance purposes, that's why I am not scheduling this with high priority at the moment. The invalidation of the cached items is not related to flushing the cache, you may have a look at the Wiki to see how this works (https://github.com/spiritix/lada-cache/wiki).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants