Net_Gearman 从工作函数内访问 job_id?
我正在尝试从我的辅助函数中访问当前作业的 job_id,以便我可以将结果保存到 memcached 中,键下的键等于当前辅助函数。有什么办法可以做到这一点吗?
<?php
class Net_Gearman_Job_Example1 extends Net_Gearman_Job_Common{
public function run($arg){
echo 'job_started' . PHP_EOL;
var_dump($arg);
$CI =& get_instance();
$CI->load->library('memcached_library', 'memcached');
// RIGHT HERE I WOULD LIKE TO KNOW JOB_ID OF CURRENTLY RUNNING JOB
$CI->memcached->add();
sleep(2);
//return array('result' => 'finished', 'output' => 'some_output');
}
}
I'm trying to access the job_id of the current job from within my worker function so I can save the result to memcached under a key that equals the current worker function. Is there any way to accomplish this?
<?php
class Net_Gearman_Job_Example1 extends Net_Gearman_Job_Common{
public function run($arg){
echo 'job_started' . PHP_EOL;
var_dump($arg);
$CI =& get_instance();
$CI->load->library('memcached_library', 'memcached');
// RIGHT HERE I WOULD LIKE TO KNOW JOB_ID OF CURRENTLY RUNNING JOB
$CI->memcached->add();
sleep(2);
//return array('result' => 'finished', 'output' => 'some_output');
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
明白了,应该早点找这个。 Net_Gearman_Job_Common 具有 $handle 和 $conn 的属性——这些就是我执行此操作所需的全部属性。
Got it, should have looks for this sooner. Net_Gearman_Job_Common has properties for $handle and $conn -- those were all I needed to do this.