是否可以使用 gearman 上传文件?再见。
问问题
744 次
2 回答
3
于 2010-12-01T20:28:18.777 回答
0
这使用 file_get_contents 读取文件,并将其传递给 GearmanClient 的 do() 方法。无需“上传”内容,它将被传输到 gearman,并进一步传输到 worker。
客户端.php
<?php
$client= new GearmanClient();
$client->addServer();
print_r(unserialize($client->do("wordcount", file_get_contents('filename.txt'))));
工人.php
<?php
$worker= new GearmanWorker();
$worker->addServer();
$worker->addFunction("wordcount", "worker_function");
while ($worker->work());
function worker_function($job)
{
return serialize(array_count_values(str_word_count($job->workload(),1)));
}
于 2011-04-15T07:45:47.290 回答