首页 > PHP + Mysql + Redis 队列邮件

PHP + Mysql + Redis 队列邮件

Mysql

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

PHP

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

Redis

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


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


// 给$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;
 }

 // 调用邮件服务代码
}

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

【热门文章】
【热门文章】