Skip to content

[5.8] Use ClusterInterface instead of PredisCluster - #28706

Merged
taylorotwell merged 1 commit into
laravel:5.8from
matthew-inamdar:5.8
Jun 3, 2019
Merged

taylorotwell merged 1 commit into
laravel:5.8from
matthew-inamdar:5.8

Conversation

@matthew-inamdar

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

Copy link
Copy Markdown
Contributor

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