database - Laravel 5 Bulk Queue Jobs w/ Same Data -
i looking way bulk queue jobs in l5 have different data.
i hoping able this:
$jobs = []; foreach($items $item) { $jobs[] = new job($item->somevalue); } queue::bulk('desired_queue', $jobs);
when using database queue driver, slow queue large number of jobs in loop each job query executed. alternatively, installed redis on windows dev box, , queueing large numbers of jobs using redis in loop fast, however, performance of job running decreased, , not sure if our production server environment support redis, time being assuming using database driver.
is there way queue large numbers of jobs , avoid performing query each 1 when using database driver?
thanks.
edit:
by looking @ how framework implements this, can following, however, not elegant , blind changes made default implementation.
$now = carbon::now()->gettimestamp(); $jobs = []; foreach($items $item) { $job = new job($item->somevalue); $payload = json_encode([ 'job' => 'illuminate\queue\callqueuedhandler@call', 'data' => ['command' => serialize(clone $job)], ]); $jobs[] = [ 'queue' => 'desired_queue', 'payload' => $payload, 'attempts' => 0, 'reserved' => 0, 'reserved_at' => null, 'available_at' => $now, 'created_at' => $now ]; } db::table('jobs')->insert($jobs);
Comments
Post a Comment