Skip to content

[5.4] Phpredis does not work with delayed redis queue #17828

Closed
@lucasfecko

Description

@lucasfecko
  • Laravel Version: 5.4.10
  • PHP Version: 7.1.0

Description:

When trying to pass a delayed job to queue when the client is set as phpredis, exception Symfony\Component\Debug\Exception\FatalThrowableError
is thrown:

Type error: Argument 2 passed to Illuminate\Redis\Connections\PhpRedisConnection::zadd() must be of the type array, integer given,

This is because PhpRedisConnection accepts array as second parameter:

/**
     * Add one or more members to a sorted set or update its score if it already exists.
     *
     * @param  string  $key
     * @param  array  $membersAndScoresDictionary
     * @return int
     */
    public function zadd($key, array $membersAndScoresDictionary)
    {
        $arguments = [];

        foreach ($membersAndScoresDictionary as $member => $score) {
            $arguments[] = $score;
            $arguments[] = $member;
        }

        return $this->command('zadd', ...$arguments);
    }

But integer (timestamp) is passed in RedisQueue:

$this->getConnection()->zadd(
    $this->getQueue($queue).':delayed', $this->availableAt($delay), $payload
);

Steps To Reproduce:

  1. Set your client in database.php config file as phpredis
  2. try to add job as delayed:
$job = new ExampleJob($data);
$this->dispatch($job->onQueue('medium')->delay(15 * 60));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions