yiisoft / yiisoft/yii2-queue

Ability to push job into Redis Queue from inside a Redis Multi block

Open
#355 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:enhancement
Dominant language
PHP
Stars
1.1k
Forks
285
Avg merge
5d 3h
Merged PRs (30d)
2

Description

If I have code that look like this:

<?php

$redis = \Yii::$app->redis;
$redis->multi();
\Yii::$app->queue->push(new SomeJob());
\Yii::$app->queue->push(new SomeJob());
$redis->exec();

The job will be pushed with QUEUED as the id, and only the last job that will be run. That's because this line read from to use an incremented number as the job id.

I propose to use something that doesn't read from redis as the value for id, such as uniqid.

Also, can I know the reason why we used hset to store the job message and only push the job id to the list, instead of directly pushing the id along with the job message to list and not using hset?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/drivers/redis/Queue.php around line 194 and reproduce the two pushes inside a Redis multi/exec block. Trace how job IDs and messages are stored, then add regression coverage showing both jobs remain distinct and runnable after exec; address the question about why hset is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, redis
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.