Sitelet https://github.com/phpredis/phpredis/issues/2696
Skip to content

Scan by type on a Redis cluster #2696

Description

@HeahDude

Hello,

I guess this is a feature request.

The TYPE parameter was added to the SCAN command on the Redis class in #1650, but it is not available on the RedisCluster class, is there a reason?

I need to scan for existing streams on a cluster, current way:

$redis = new \RedisCluster(null, $config['servers']);
$streams = [];

foreach ($redis->_masters() as $master) {
    $cursor = 0;
    do {
        $result = $redis->rawcommand($master, 'SCAN', $cursor, 'TYPE', 'STREAM');
        $cursor = (int) $result[0];

        if (count($result[1] ?? []) > 0) {
            array_push($streams, ...$result[1]);
        }
    } while ($cursor !== 0);
}

Expected:

$redis = new \RedisCluster(null, $config['servers']);
$streams = [];

foreach ($redis->_masters() as $master) {
    $cursor = null;
    do {
        $result = $redis->scan($cursor, $master, type: 'STREAM');

        if ($result !== false) {
            array_push($streams, ...$result);
        }
    } while ($cursor !== 0);
}

Thanks!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    major-version-bumpThings we can't merge until a major version change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions