Laravel-如何在分配工作后如何获取Redis工作ID?

时间:2018-07-21 07:47:45

标签: php laravel redis laravel-5.2

当我这样称呼时:

$data = \Redis::lrange('queues:high', 0, -1);
print_r($data[0];);

我看到了:

{
  "job": "Illuminate\\Queue\\CallQueuedHandler@call",
  "data": {
    "commandName": "App\\Jobs\\SyncProduct",
    "command": "..."
  },
  "id": "CXAfF3aFL6CT06X0sI1veXADgv8ipqUi",
  "attempts": 1
}

如何从laravel代码,内部作业或调度程序对象中获取此作业ID(CXAfF3aFL6CT06X0sI1veXADgv8ipqUi)?

1 个答案:

答案 0 :(得分:2)

从您的工作内部,您可以尝试访问基础工作:

// for a job using the `InteractsWithQueue` trait
$this->job->getJobId();