$ php worker.php &
$ php worker.php &
$ php worker.php &
$ php worker.php &
$ php worker.php &
$ php client.php
Created
March 24, 2015 04:41
-
-
Save anonymous/491ed9e10283ee7acd12 to your computer and use it in GitHub Desktop.
Gearman Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client = new GearmanClient(); | |
$client->addServer(); | |
// Data Generator | |
$queue = []; | |
for($i = 0;$i < 100000;$i++){ | |
$client->doBackground("send",$i) . "\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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