crontab is too inefficient. Is there a more efficient one
crontab is too inefficient. Is there a more efficient one
Use the redis queue, data lpush enters, and then open another process, while(true){brpop/rpop queue}
The following uses php as an example:
Code in a.php file
<code>$redis->Redis(); $redis->connect($host, $port, $db); $redis->lpush('list', $data);</code>
Code in the b.php file
<code>$redis->Redis(); $redis->connect($host, $port, $db); while(true) { $data = $redis->brpop('list', 0); if ($data) { // 连接mysql操作 // 插入数据 } }</code>
Execute b.php file with php command
<code>php b.php</code>
It is recommended to use asynchronous processing
Only operate the redis queue, and use other asynchronous programs to achieve synchronization