<?php require_once realpath(dirname(__FILE__) . '/..') . '/file_queue.php'; $loop = false; ini_set('max_execution_time', 0); $workerId = uniqid(); $fq = new FileQueue(); $callback = function ($uid, $payload) { sleep(1); echo "payload: " . serialize($payload) . "; "; return true; }; while (true) { $start = microtime(true); ob_start(); echo "wid: {$workerId} >> "; $sleep = false; $job = $fq->job(); if (!$job) { echo 'no jobs found, sleeping'; $sleep = 10000000; } else { echo "got job id: {$job->id()}; "; if (-1 !== ($status = $job->dispatch($callback))) { echo "dispatch status: " . var_export($status, true) . '; '; } else { echo 'job was locked by another worker or is no longer available'; } $sleep = 500000; } echo " | took: " . round((double) microtime(true) - $start, 4) . " s \n";
<?php require_once realpath(dirname(__FILE__) . '/..') . '/file_queue.php'; $fq = new FileQueue(); $fq->remove('3ccba07df704ecde89ec6f671ccd768d69b20a43');
<?php require_once realpath(dirname(__FILE__) . '/..') . '/file_queue.php'; ob_start(); echo 'thread id: ' . uniqid(true) . ' | '; $fq = new FileQueue(); $uid = '1234-123456-12345678901'; //$uid = hash( 'sha1', uniqid( true ) ); $payload = array('some', 'random', 'data', hash('crc32', uniqid(true))); //$r = $fq->add( $uid, $payload, function ($uid,$payload) { echo serialize( $payload ); return true; } ); $r = $fq->add($uid, $payload); echo 'return: ' . var_export($r, true) . "\n"; ob_end_flush();
<?php require_once realpath(dirname(__FILE__) . '/..') . '/file_queue.php'; echo "wid: " . uniqid(true); $jobs = 5000; $fq = new FileQueue(); for ($i = 0; $i < $jobs; $i++) { $id = hash('sha1', uniqid(true)); $payload = array('some', 'random', 'data', hash('crc32', uniqid(true))); echo "adding job id: {$id}\n"; $fq->add($id, $payload, $enqueue = true); //usleep(100000); }
<?php require_once realpath(dirname(__FILE__) . '/..') . '/file_queue.php'; $fq = new FileQueue(); $job = $fq->add(null, array(1, 2, 3), true); var_dump($job); $job->dispatch(function ($id, $payload) { $payload[] = uniqid('meh', true); echo serialize($payload); return true; }); var_dump($job); //$job = $fq->job(); //var_dump($job); //$fqj = new FileQueueJob( $fq->config ); //$fqj->create(); /*$fqj->create(); var_dump($fqj); $fqj->enqueue(); $fqj->complete(); $fqj->archive(); var_dump($fqj);*/ //$fqj->load( '/home/nocive/git/File-Queue/queue/tmp/job-uid-1234-12345' ); //var_dump($fqj); //var_dump($r);