Home > Backend Development > PHP Tutorial > Redis实现计划任务方案

Redis实现计划任务方案

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:25:39
Original
1708 people have browsed it

项目目前有这样一个需求:系统定时地去访问一些网站并得到返回结果(需要访问的网站保存到MySQL中),我想使用Redis实现队列 + Linux定时任务来完成,但是这方面没有什么经验,Redis和Linux都只是懂一点皮毛,请大家谈谈自己的想法,集思广益一下。

回复内容:

项目目前有这样一个需求:系统定时地去访问一些网站并得到返回结果(需要访问的网站保存到MySQL中),我想使用Redis实现队列 + Linux定时任务来完成,但是这方面没有什么经验,Redis和Linux都只是懂一点皮毛,请大家谈谈自己的想法,集思广益一下。

先入队列$redis->lpush('test:queue',$json)//$json是需要处理的参数
crontab里设置定时任务,程序大概是

while ($job = $redis->rPop('test:queue')) {
    var_dump($job);//解析$job处理
}
Copy after login

crontab 频率最快一分钟执行一次,用它处理队列可能太慢。

Related labels:
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
Latest Issues
php redis connection problem
From 1970-01-01 08:00:00
0
0
0
About a small error in the redis manual
From 1970-01-01 08:00:00
0
0
0
python2.7 - django cannot connect to redis
From 1970-01-01 08:00:00
0
0
0
I can't connect to redis using php
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template