What does the Laravel queue mean, what is the principle of implementation, and what is the general scenario used in the queue?
Reply content:
What does the Laravel queue mean, what is the principle of implementation, and what is the general scenario used in the queue?
The queue here should refer to the message queue, the operations of the queue are queued and out of team. That is, you have a program that produces content and then the queue (producer)
Another program reads content, content out of the queue (consumer).
And when does the queue use it?
当你不需要立即获得结果,但是并发量又不能无限大的时候,差不多就是你需要使用消息队列的时候。
Most often encountered is the app push notification, when the app user group triggered a lot of actions to notify the target user, it is not possible to execute push code in each operation will reduce the processing speed of the interface and users do not need to know whether there is no notification to the target user as long as the operation can be successful, Instead, the operation data is inserted into a storage ( memcache
, redis
etc.), and then a process is executed to execute the data push within the store.
Laravel 5.2 Service-Queue
Is the data structure inside the queue, the typical operation is first-out, all have (first-out) such requirements of the task can use this data structure.
More information on the data structure of the queue can be searched by the search engine by itself. Because queues also have circular queues, priority queues, and many other categories.
The implementation of the principle, in fact, is to achieve the general operation of the queue, such as the into row. Generally will implement a plurality of driver, so-called driver, is how to implement the queue. such as text file mode, DB mode, Redis, Monolog.
Usage scenarios are usually queued tasks, such as robbing tickets, killing seconds, etc.