Skip to content

Instantly share code, notes, and snippets.

@cloneko
Forked from anonymous/README.md
Last active August 29, 2015 14:17
Show Gist options
  • Save cloneko/67f4faadc57a2940728e to your computer and use it in GitHub Desktop.
Save cloneko/67f4faadc57a2940728e to your computer and use it in GitHub Desktop.

Usage

$ php worker.php &
$ php worker.php &
$ php worker.php &
$ php worker.php &
$ php worker.php &
$ php client.php
<?php
$client = new GearmanClient();
$client->addServer();
// Data Generator
$queue = [];
for($i = 0;$i < 100000;$i++){
$client->doBackground("send",$i) . "\n";
}
<?php
$worker = new GearmanWorker();
$worker->addSErver();
$worker->addFunction('send','send_function');
while ($worker->work());
function send_function($job){
sleep(1);
echo $job->workload();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment