开发者

Php gearman file upload [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the开发者_如何学Go help center. Closed 10 years ago.

Is it possible upload a file using gearman ? Bye.


Use standard php to upload the file. Read the bytes of the file into a variable and pass to the server.

A client has some form of blob data and wants to farm out the processing of the data to the cloud. To do so, it makes a connection to the Server and requests that the server perform some function on that data.

Read the docs.


This reads the file using file_get_contents, it is passed on to the do() method of GearmanClient. There's no need to "upload" the content, it will be transmitted to gearman, and further to the worker.

client.php

<?php
$client= new GearmanClient();
$client->addServer();
print_r(unserialize($client->do("wordcount", file_get_contents('filename.txt'))));

worker.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)));
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜