Net_Gearman 从工作函数内访问 job_id?

发布于 2024-12-13 08:25:34 字数 651 浏览 3 评论 0原文

我正在尝试从我的辅助函数中访问当前作业的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿童谣 2024-12-20 08:25:34

明白了,应该早点找这个。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文