How does PHP monitor whether the redis queue has a value in the background and execute the script if there is a value?
How does PHP monitor whether the redis queue has a value in the background and execute the script if there is a value?
<code class="php">$idle = 0; $maxWait = 10; $interval = 50; //50ms while(true) { if($redis->lLen() > 0 ) { $idle = 0; //doing some things continue; } //这里很重要 usleep($interval * ($idle % $maxWait)); $idle++; }</code>
crontab