A picture of the opening, the content depends on editing! ! !
The editor recently encountered a requirement (environmental LNMP), to process tasks at the minute level, and also to customize the number of data increase or decrease and switch activation.
After talking, do the friends have ideas? Of course, there are many ways. I will list them for you first, and then you will choose to do them.
(1) The daemon process, write a PHP script, an infinite loop (while(true)), keep listening, and then write a custom time to sleep on sleep for processing
(2) Then swoole is on the court, there is a second-level timing task, of course, this also needs to install swoole extension, if you have conditions, you can try
(3) This is my idea (crontab), the processing method of linux original sound, of course, this can only be set in minutes (but it has completely met my needs)
Then let's move on:
First of all, we write a configuration method, which is specifically used to set the number of items to be processed every few minutes, whether to open or not
Then we will write a processing method
The status is the status of the switch, 1 is on, 0 is off, and there is a time field after that. This is for time processing. For example, if it is set to execute once every 3 minutes, then set the current time in the time field plus 3 in the configuration. After a few minutes, this can meet the needs. Of course, the following logic can be completely customized according to your actual needs.
For example, we can query how many items to process, or what data to process, we can configure it in the configuration, and then query the configuration conditions to process the corresponding data.
Finally, configure crontab in linux
Of course, this is just a simple example, how to deal with massive data, you still need to think about it to do business processing, this is more suitable for medium and small amounts of data processing temporarily
Finally, I secretly ask, have you started?