Home >Backend Development >PHP Tutorial >Laravel5.2, for scheduled tasks, should I use the crontab of the service or the queue?
For example, add a new series of activities with a start time, and then automatically set it to the start state when it reaches the start time, and set it to the end state when it ends.
Also, should we query the database or put it in redis?
For example, add a new series of activities with a start time, and then automatically set it to the start state when it reaches the start time, and set it to the end state when it ends.
Also, should I query the database or put it in redis?
Strictly speaking, the queue is only for sending messages, not for tasks (although it can also be achieved through delayqueue), but it is best to use crontab
The start and end time of an activity can be determined directly in the code. It is best to have a background to control the start and end time of this series of activities. If your business scenario is different, based on what you said, it is recommended to use crontab, which is simple and direct
As for querying data, my personal suggestion is to store the database, query redis, and update at the same time
Querying the database is slow and concurrency is low
If there are many online activities at the same time and there is a certain number of concurrency, you should prepare for caching to prevent the database from hanging.