I wrote a very simple queue using redis, but I think my implementation is bad, so I want to ask for a better solution. Below is a simple flow chart of my problem.
- some program push data into a redis list
- a php program loop forever, check if the list if empty, if not empty then pop the nodes in the list into MySQL.
Step 1 is fine, but I have used
while (true) in step 2, which can cause a lot of CPU waste. Any good way that can do pop operation when the list is not empty?