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

[5.8] Use ClusterInterface instead of PredisCluster #28706

Merged
merged 1 commit into from
Jun 3, 2019
Merged

[5.8] Use ClusterInterface instead of PredisCluster #28706

merged 1 commit into from
Jun 3, 2019

Conversation

matthew-inamdar
Copy link
Contributor

@matthew-inamdar matthew-inamdar commented Jun 3, 2019

The issue

There is an issue when running the artisan cache:clear command with a redis cluster using the Predis library:

php artisan cache:clear

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

The reason why

There is logic to check whether the connection is using a cluster or single node, which determines how the flush command should be executed. However the condition for this check isn't working correctly.

The current logic checks to see if the connection is an instance of Predis\Connection\Aggregate\PredisCluster, however when I was debugging the error I noticed the instance I got was of Predis\Connection\Aggregate\RedisCluster.

The proposed solution

Both of these classes implement the Predis\Connection\Aggregate\ClusterInterface interface, so by checking if the connection is an instance of this interface instead, the error no longer occurs.

Supporting info

My Redis config in config/database.php is:

'redis' => [
    'client' => 'predis',

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

    'clusters' => [
        'default' => [
            'parameters' => [
                'host' => '127.0.0.1',
                'password' => null,
                'port' => 6379,
            ],
        ],
    ],

],

@GrahamCampbell GrahamCampbell changed the title Use ClusterInterface instead of PredisCluster [5.8] Use ClusterInterface instead of PredisCluster Jun 3, 2019
@taylorotwell taylorotwell merged commit 7db4308 into laravel:5.8 Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants