コード例 #1
0
ファイル: get_info.php プロジェクト: koolkt/python_crawler
        }
        while ($n and $this->redis->llen($n)) {
            (yield $this->redis->lpop($n));
        }
        return null;
    }
    /*
     *      Creates a generator then gets every element from the queue one by one
     */
    function rq_get_data($name)
    {
        $item_generator = $this->rq_gen_pop($name . ':product_info');
        print_r($item_generator);
        foreach ($item_generator as $item) {
            echo $item;
        }
    }
    function send_info($info, $name)
    {
        $info = json_encode($info);
        $this->redis->rpush($name . ':product_info', info);
    }
    function close()
    {
        $redis->close();
    }
}
$r = new RedisQueue();
$r->connect();
$r->rq_get_data("http://le-narguile.com");