-5

是否可以使用 gearman 上传文件?再见。

4

2 回答 2

3

使用标准 php 上传文件。将文件的字节读入变量并传递给服务器。

客户拥有某种形式的 blob 数据,并希望将数据处理外包给云。为此,它与服务器建立连接并请求服务器对该数据执行某些功能。

阅读文档。

于 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 回答