Php-redis is used to send emails to all users. the data volume is large, and what is the idea?

Source: Internet
Author: User
Currently, it is a bit technical. In php code, all the arrays requiring the request interface are put into the redis storage, and then the array brpop is cyclically generated. but isn't this process executed by php code? After php times out, the entire process is not interrupted yet? Currently, it is a bit technical.

In the php code, put all the arrays requiring the request interface into the redis storage,
Then we use a loop to pop the array. but isn't this process executed by php code?

After php times out, the entire process is not interrupted yet?

Reply content:

Currently, it is a bit technical.

In the php code, put all the arrays requiring the request interface into the redis storage,
Then we use a loop to pop the array. but isn't this process executed by php code?

After php times out, the entire process is not interrupted yet?

Start a php script and run it on the command line.

Upstairs.
For example. Redis is A data pool, and both A and B can connect to it. A is your current task. it is only responsible for writing data to Redis, B is another task (for example, Charles started an endless loop script using the command line method). B is only responsible for querying/deleting mail data in Redis.

Dead Loop script pseudo code:

Set_timelimit (0); // enables this PHP program to execute while (true) without a limited time {$ row = $ redisInstance-> shiftGroup ('email '); // if all the emails to be sent are an array, retrieve the first if (empty ($ row) {sleep (1); // rest for 1 second continue ;} sendMail ($ row );}

You can use Redis's Pub/Sub mechanism to establish a simple message queue using NodeJS.

Redis. subscribe ('email ', 'MS', 'Push', function (err, count) {}); redis. on ('message', function (chan, msg) {// process the message to be sent });

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.