略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Gearman

2024-11-14

Gearman

add a noteadd a note

User Contributed Notes 3 notes

up
3
jon dot skarpeteig at gmail dot com
9 years ago
Unfortunately there's no manager in the pecl extension. If you want to make use of admin features, check out: http://pear.php.net/package/Net_Gearman which implements the administrative protocol in Manager.php as defined in: http://gearman.org/?id=protocol
up
-3
spacewalker2002 at ukr dot net
9 years ago
You can use this syntax:

<?php
   $worker
= new GearmanWorker();
  
$worker->addServer();
  
$worker->addFunction(new MyClass($test), 'myMethod');

class
MyClass
{
   public function
__construct($test)
   {
      
$this->test = $test;
   }

   public function
myMethod(GearmanJob $job)
   {
     
// you can access to $this->test;
  
}
}
up
-4
Anonymous
9 years ago
For my previous comment:

this line:
<?php
$worker
->addFunction(new MyClass($test), 'myMethod');
?>

change to:

<?php
$worker
->addFunction($taskName, array(new MyClass(), 'myMethod'));
?>

官方地址:https://www.php.net/manual/en/book.gearman.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3