Lionel F. Lebeau - 2016-03-09 18:55:23
Using one Worker at a time :
If you run only one Worker and it has to process a bunch of records, you may run into a race to access the same record when a new Worker is launched and the precedent one has not finished its job.
You can check if a pid file exists at construct phase and, if not, create it.
It will be deleted at the end of the process.
As the items are processed in order, you can optimize the database access by dropping the markItemAsBeingProcessed($item) function.
You can also launch more than one Worker at a time. There are different ways to do it (exec, pnctl_fork, curl_multi_exec, gearman, fsockopen...).