same stuff here, still trying to figure out how to delete delayed job. you're right the key is a big json object, and I can't just recreate same big json object as a key
I think it could be done with ZSCAN where you scan for that job json and at the end ignore the attempts probably. luckily my object is not so big, passing like 4 primary keys only. you're doing something wrong if you pass whole email template. you should pass only path to your blade email template file. will try to implement it tomorrow and post my results
Here it is
/**
* @param $job_id
* @param string $queue is optional, if not passed then using 'default' queue
*
* @return int 1 if removed, 0 if not removed
*/
public static function deleteDelayedJob($job_id, $queue = 'default') {
$redis_queue_instance = Queue::getRedis();
// use redis ZSCAN with MATCH to find by pattern, its similar to SQL LIKE %jobid%
$res = $redis_queue_instance->zscan('queues:'.$queue.':delayed', 0, 'MATCH', "*$job_id*");
if ($res) { // make sure result is found
if (isset($res[1])) { // first element is cursor, second is array with result
$job_arr = $res[1];
if (isset($job_arr[0])) { // make sure second element is array and has index 0
$job = $job_arr[0]; // get the job id
// remove the job which is literally removing element from Sorted Set
return $redis_queue_instance->zrem('queues:'.$queue.':delayed', $job);
}
}
}
return 0; // not removed
// throw new RuntimeException("Job id: $job_id not found for queue: $queue");
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community