PluginProbe
Disk Usage Insights / 1.9
Disk Usage Insights v1.9
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
disk-usage-insights / vendor / mgleis / php-sqlite-job-queue / demo.php

demo.php in Disk Usage Insights 1.9, at vendor/mgleis/php-sqlite-job-queue/demo.php

31 lines 736 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Mgleis\PhpSqliteJobQueue\Job;
4 use Mgleis\PhpSqliteJobQueue\Queue;
5 use Mgleis\PhpSqliteJobQueue\Worker;
6
7 require_once 'vendor/autoload.php';
8
9 $queue = new Queue("jobs.sqlite", 'queue');
10 $queue->push('hi');
11 $queue->push("a string");
12 $queue->push(["an" => "array"]);
13 $queue->push([0, 1, 2, 3, 4]);
14 $queue->push(['type' => 'SendEmail', 'to' => '...']);
15
16 $w = new Worker($queue);
17 $w
18 ->withMaxTotalRuntimeInSeconds(60)
19 ->withMaxJobCount(60)
20 ->withSleepTimeBetweenJobsInMilliseconds(1)
21 ->withSleepTimeOnEmptyQueueInMilliseconds(100)
22 ;
23 $w->process(function(Job $job) {
24 echo "starting...\n";
25 echo $job->id . "\n";
26 var_dump($job);
27 echo "done...\n";
28 });
29
30 echo "remaining jobs: " . $q->size() . "\n";
31