Php gearman文件上传[关闭]

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)));
}