queue:work和queue:listen有什么区别 [英] What is the difference queue:work and queue:listen

查看:737
本文介绍了queue:work和queue:listen有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白Laravel queue:work和Laravel queue:listen

I can't understand what's the difference between Laravel queue:work and Laravel queue:listen

我可以看到:

  • 队列:收听给定的队列
  • 工作:处理队列中的下一个工作

但是仍然不明白,因为我都尝试过,如果有任何新队列(工作选项"不仅运行一次),两者都会运行队列.

But still don't get it, because I've tried both, both will run queue if there is any new queue ("work option" not just running once)

我不是在谈论守护程序选项.只是这两个.

I'm not talking about the daemon option. Just these both.

推荐答案

直到Laravel 5.2您拥有:listen:work.

Until Laravel 5.2 you had :listen and :work.

Work将处理队列中的第一个作业.

Work would process the first job in the queue.

Listen将在处理所有作业时对其进行处理.

Listen would process all jobs as they came through.

在Laravel 5.3 +中,情况不再如此. Listen仍然存在,但已弃用并计划在5.5中将其删除.您现在应该首选:work.

In Laravel 5.3+ this is no longer the case. Listen still exists, but it is deprecated and slated for removal in 5.5. You should prefer :work now.

Work现在可以一个接一个地处理作业,但是有很多可以配置的选项.

Work now process jobs one after the other, but have a plethora of options you can configure.

修改

以上内容在发布时是正确的,但是从那以后,情况有所改变.

The above was true at the time of the posting, but since then things have been changed a bit.

queue:work.这将是一个长期存在的过程,在性能成为问题的情况下将是有益的.这将使用应用程序的缓存版本,并且不会在每次处理作业时重新引导应用程序.

queue:work should be preferred when you want your queue's to run as a daemon. This would be a long-lived process that would be beneficial where performance was an issue. This will use a cached version of the application and does not re-bootstrap the application every time a job is processed.

queue:listen应该在您不关心性能或不想在更改代码后不必重新启动队列时使用.

queue:listen should be used when you don't care about performance or you don't want to have to restart the queue after making changes to the code.

  • 他们都将按接收的顺序将作业从队列中逐一弹出.
  • 他们都几乎共享 可以传递给他们的完全相同的选项.
  • They'll both pop jobs off the queue 1-by-1 as received.
  • They both share almost the exact same options that can be passed to them.

这篇关于queue:work和queue:listen有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆