My idea is to delay the distribution of a task through the queue, which is to trigger it after 2 hours, and then send a text message in the task. The following is the document link:
Create a table to store the user’s mobile phone number, text message content, and the time it should be sent. Users can add a new row of records with one click. Set a scheduled task, check it every minute, send it when the time is up, and delete the record after sending it
Put the name of the task to be executed and the execution time into the redis ordered set, and then check the score of the redis ordered set regularly, and if it is within the range, take out the execution task
When the user operates, he will definitely save an operation time in the table, and the daemon will keep querying until it sends a text message in two hours
Linux uses crontab and the interface system like window has its own customized tasks. Use the scheduled task curl to specify the php file, or use php to execute the php file. In this case, by performing scheduled access every minute (similar to polling), when accessing the PHP file, read the data of the stored data table (conditional two-hour data), you need to throw the data into the queue (to avoid when the amount of data is too large, Sending a large amount of information leads to excessive use of server resources), and finally extract quantitative data from the queue and send the data
My idea is to delay the distribution of a task through the queue, which is to trigger it after 2 hours, and then send a text message in the task.
The following is the document link:
Queue delayed distribution
SMS notification
Create a table to store the user’s mobile phone number, text message content, and the time it should be sent.
Users can add a new row of records with one click.
Set a scheduled task, check it every minute, send it when the time is up, and delete the record after sending it
Put the name of the task to be executed and the execution time into the redis ordered set, and then check the score of the redis ordered set regularly, and if it is within the range, take out the execution task
When the user operates, he will definitely save an operation time in the table, and the daemon will keep querying until it sends a text message in two hours
This is the need for timers and message queues. . .
Linux uses crontab and the interface system like window has its own customized tasks. Use the scheduled task curl to specify the php file, or use php to execute the php file. In this case, by performing scheduled access every minute (similar to polling), when accessing the PHP file, read the data of the stored data table (conditional two-hour data), you need to throw the data into the queue (to avoid when the amount of data is too large, Sending a large amount of information leads to excessive use of server resources), and finally extract quantitative data from the queue and send the data
Use crontab to run the task queue of the database
You can use a PHP asynchronous framework, such as Workerman or Swoole, to create a timer and execute tasks when you need them! ! !
Save the time and event to be triggered, the script will run the data every minute, and execute it when the time is up. It’s the simplest