无需重启即可清除 Laravel 队列缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47435222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:59:36  来源:igfitidea点击:

Clear Laravel Queue Cache without restarting

phplaravelweb

提问by Assem

In my application, every customer has a kind of complex class in which we do some search and replaces for that specific customer. I run Queue workers to run a daily sync with eBay for every single customer to do some kind of search and replaces.

在我的应用程序中,每个客户都有一种复杂的类,我们可以在其中为该特定客户进行一些搜索和替换。我运行 Queue Workers 以每天与 eBay 同步,以便每个客户进行某种搜索和替换。

The problem is Laravel queues caches the code for a good deal of time and if I want to go and change any customer class file (Which happens frequently), I will have to restart queue workers (Which may stop a running job that I don't intend to stop).

问题是 Laravel 队列将代码缓存了很长时间,如果我想更改任何客户类文件(经常发生),我将不得不重新启动队列工作程序(这可能会停止我不做的正在运行的工作) t打算停止)。

So my question is, how to force Laravel Queue to reread the new code without restarting workers?

所以我的问题是,如何强制 Laravel Queue 在不重启工作人员的情况下重新读取新代码?

回答by Adam Winnipass

Open an extra terminal and use the artisan command

打开一个额外的终端并使用 artisan 命令

php artisan queue:restart

回答by Toskan

This command will instruct all queue workers to gracefully "die" after they finish processing their current job so that no existing jobs are lost.

此命令将指示所有队列工作人员在处理完当前作业后优雅地“死亡”,以便不会丢失现有作业。

You may gracefully restart all of the workers by issuing the queue:restart command:

您可以通过发出 queue:restart 命令优雅地重新启动所有工作程序:

php artisan queue:restart

php artisan queue:restart

source: https://laravel.com/docs/5.8/queues#running-the-queue-worker

来源:https: //laravel.com/docs/5.8/queues#running-the-queue-worker

so the full chain of commands should be (maybe) this:

所以完整的命令链应该(也许)是这样的:

composer dump-autoload
php artisan optimize
php artisan clear-compiled
php artisan cache:clear
php artisan view:clear
php artisan route:cache
php artisan queue:restart

I left out the config cache command on purposebecause I don't want to run it initially. Running it, will actually start to cache your config file afaik so I dont want that.

故意省略了 config cache 命令因为我不想最初运行它。运行它,实际上会开始缓存你的配置文件 afaik 所以我不想要那个。

I'm answering because I want to store my own answer to evernote, to never ever have to deal with that bs again

我回答是因为我想将我自己的回答存储到 Evernote,永远不必再处理那个 bs

回答by Антон Баранов

you will have not cache if you use code:

如果您使用代码,您将没有缓存:

php artisan queue:listen

Also, interest command:

另外,兴趣命令:

php artisan queue:work --queue=system,hot,default --tries=10 --timeout=10  --stop-when-empty