master

laravel/framework

Last updated at: 29/12/2023 09:24

PredisClusterConnection.php

TLDR

This file contains the PredisClusterConnection class, which extends the PredisConnection class. It defines a method called flushdb, which is used to flush the selected Redis database on all cluster nodes.

Methods

flushdb

Flushes the selected Redis database on all cluster nodes.

Classes

PredisClusterConnection

This class extends the PredisConnection class. It provides the functionality to flush the selected Redis database on all cluster nodes.

<?php

namespace Illuminate\Redis\Connections;

use Predis\Command\Redis\FLUSHDB;
use Predis\Command\ServerFlushDatabase;

class PredisClusterConnection extends PredisConnection
{
    /**
     * Flush the selected Redis database on all cluster nodes.
     *
     * @return void
     */
    public function flushdb()
    {
        $command = class_exists(ServerFlushDatabase::class)
            ? ServerFlushDatabase::class
            : FLUSHDB::class;

        foreach ($this->client as $node) {
            $node->executeCommand(tap(new $command)->setArguments(func_get_args()));
        }
    }
}