The requirement is that after the user performs an operation, count down for two hours, and then perform another operation at the time
But now there is no way to time these two hours.
Do you have any good ideas
巴扎黑2017-05-16 13:06:54
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
PHPz2017-05-16 13:06:54
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
PHP中文网2017-05-16 13:06:54
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
曾经蜡笔没有小新2017-05-16 13:06:54
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
过去多啦不再A梦2017-05-16 13:06:54
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
滿天的星座2017-05-16 13:06:54
You can use a PHP asynchronous framework, such as Workerman or Swoole, to create a timer and execute tasks when you need them! ! !
PHP中文网2017-05-16 13:06:54
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