master

laravel/framework

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

PhpRedisClusterConnection.php

TLDR

This file contains the PhpRedisClusterConnection class which extends the PhpRedisConnection class. It includes a method called flushdb which flushes the selected Redis database on all master nodes.

Methods

flushdb

This method flushes the selected Redis database on all master nodes. It takes no arguments. If called with the argument 'ASYNC', it will flush the database asynchronously using the flushdb command with the 'async' option. Otherwise, it flushes the database synchronously using the flushdb command.

Classes

PhpRedisClusterConnection

This class extends the PhpRedisConnection class and is responsible for managing connections to a Redis cluster. It includes the flushdb method which flushes the selected Redis database on all master nodes.

<?php

namespace Illuminate\Redis\Connections;

class PhpRedisClusterConnection extends PhpRedisConnection
{
    /**
     * Flush the selected Redis database on all master nodes.
     *
     * @return mixed
     */
    public function flushdb()
    {
        $arguments = func_get_args();

        $async = strtoupper((string) ($arguments[0] ?? null)) === 'ASYNC';

        foreach ($this->client->_masters() as $master) {
            $async
                ? $this->command('rawCommand', [$master, 'flushdb', 'async'])
                : $this->command('flushdb', [$master]);
        }
    }
}