PHP + Mysql + Redis 队列邮件

WBOY
Release: 2016-06-06 20:38:23
Original
1152 people have browsed it

Mysql

所有的用户的邮箱都存在这Mysql

PHP

读取用户邮箱 生成发送内容

Redis

怎么用这个东西做队列 不懂?

回复内容:

Mysql

所有的用户的邮箱都存在这Mysql

PHP

读取用户邮箱 生成发送内容

Redis

怎么用这个东西做队列 不懂?

http://segmentfault.com/q/1010000002518573/a-1020000002518892

<code>// 给$id设置需要的信息,譬如邮件地址、内容
$this->_redis->hMset($id, $struct);

// push到名为'queue'的队列
$this->_redis->lPush('queue', $id);

while (true) {
 // 读取一个队列任务
 $task = $redis->brPop('queue', 10);

 // 获取队列任务的信息
 if ($task) {
    list ($name, $id)  = $task;
 }

 // 调用邮件服务代码
}
</code>
Copy after login

你可能需要php redis文档https://github.com/phpredis/phpredis

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template