当前位置: 首页>>代码示例>>PHP>>正文


PHP Resque::generateJobId方法代码示例

本文整理汇总了PHP中Resque::generateJobId方法的典型用法代码示例。如果您正苦于以下问题:PHP Resque::generateJobId方法的具体用法?PHP Resque::generateJobId怎么用?PHP Resque::generateJobId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Resque的用法示例。


在下文中一共展示了Resque::generateJobId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $monitor Set to true to be able to monitor the status of a job.
  * @param string $id Unique identifier for tracking the job. Generated if not supplied.
  *
  * @return string
  */
 public static function create($queue, $class, $args = null, $monitor = false, $id = null)
 {
     if (is_null($id)) {
         $id = Resque::generateJobId();
     }
     if ($args !== null && !is_array($args)) {
         throw new InvalidArgumentException('Supplied $args must be an array.');
     }
     Resque::push($queue, array('class' => $class, 'args' => array($args), 'id' => $id, 'queue_time' => microtime(true)));
     if ($monitor) {
         Resque_Job_Status::create($id);
     }
     return $id;
 }
开发者ID:SoftwarePunt,项目名称:php-resque,代码行数:25,代码来源:Job.php

示例2: enqueue

 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  *
  * @return string|boolean Job ID when the job was created, false if creation was cancelled due to beforeEnqueue
  */
 public static function enqueue($queue, $class, $args = null, $trackStatus = false)
 {
     $id = Resque::generateJobId();
     $hookParams = array('class' => $class, 'args' => $args, 'queue' => $queue, 'id' => $id);
     try {
         Resque_Event::trigger('beforeEnqueue', $hookParams);
     } catch (Resque_Job_DontCreate $e) {
         return false;
     }
     Resque_Job::create($queue, $class, $args, $trackStatus, $id);
     Resque_Event::trigger('afterEnqueue', $hookParams);
     return $id;
 }
开发者ID:varvar,项目名称:php-resque,代码行数:23,代码来源:Resque.php

示例3: enqueue

 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  *
  * @return string|boolean Job ID when the job was created, false if creation was cancelled due to beforeEnqueue
  */
 public static function enqueue($queue, $class, $args = null, $trackStatus = false)
 {
     if (self::$runInBackground) {
         $id = Resque::generateJobId();
         $hookParams = array('class' => $class, 'args' => $args, 'queue' => $queue, 'id' => $id);
         try {
             Resque_Event::trigger('beforeEnqueue', $hookParams);
         } catch (Resque_Job_DontCreate $e) {
             return false;
         }
         Resque_Job::create($queue, $class, $args, $trackStatus, $id);
         Resque_Event::trigger('afterEnqueue', $hookParams);
         return $id;
     } else {
         $obj = new $class();
         $obj->args = $args;
         if (method_exists($obj, 'setUp')) {
             $obj->setUp();
         }
         if (method_exists($obj, 'perform')) {
             $obj->perform();
         }
         if (method_exists($obj, 'tearDown')) {
             $obj->tearDown();
         }
         return true;
     }
 }
开发者ID:artox-lab,项目名称:php-resque,代码行数:38,代码来源:Resque.php


注:本文中的Resque::generateJobId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。