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 / readme.md

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

62 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # PHP SQLite Job Queue
2
3 A minimal job queue library written in PHP that persists data with SQLite.
4
5 Use it for small projects / prototypes with at most hundreds or thousands of jobs.
6
7 ## Install
8
9 composer require mgleis/php-sqlite-job-queue
10
11 ## Usage
12
13 ### The Main Use Cases
14
15 #### Add a new job
16
17 $queue = new Queue('queue.sqlite');
18 $queue->push("a string");
19 $queue->push(["an" => "array"]);
20 $queue->push([0, 1, 2, 3, 4]);
21 $queue->push(['type' => 'SendEmail', 'to' => '...']);
22
23 #### Process jobs with workers
24
25 $worker = new Worker($queue);
26 $worker->process(function(Job $job) {
27 $payload = $job->payload;
28 if ($payload['type'] == 'SendEmail')
29 send_email(...);
30 });
31
32 #### Worker Configuration
33
34 You have several options to configure the worker. The options should be self-explanatory:
35
36 // optional configuration
37 $worker
38 ->withMaxTotalRuntimeInSeconds(60)
39 ->withMaxJobCount(100)
40 ->withSleepTimeBetweenJobsInMilliseconds(1)
41 ->withSleepTimeOnEmptyQueueInMilliseconds(100);
42
43 ### Edge Cases
44
45 ### Determine Size of the queue
46
47 $size = $queue->size();
48
49 ### Get a specific job
50
51 $job = $queue->get(12345);
52
53 ### Handling Errors
54 TBD
55
56 ### Handling Timeouts (reserved jobs)
57 TBD
58
59 ### Handling database locks
60 TBD
61
62