Home > Backend Development > PHP Tutorial > Laravel5.2, for scheduled tasks, should I use the crontab of the service or the queue?

Laravel5.2, for scheduled tasks, should I use the crontab of the service or the queue?

WBOY
Release: 2023-03-01 16:06:01
Original
1708 people have browsed it

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?

Reply content:

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

  1. Querying the database is slow and concurrency is low

  2. 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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template