ホームページ  >  記事  >  バックエンド開発  >  redis - php-resque遇到坑

redis - php-resque遇到坑

WBOY
WBOYオリジナル
2016-06-06 20:24:051339ブラウズ

Resque::enqueue存数据放到redis队列,worker拿出来json_decode有时是不完整的(访问量大的时候出现几率可能更高,没完全验证)!
郁闷极至。通读了多编php-ressue代码,也很清晰,看不出啥问题啊。 php-ressue中打log如下(Rescue.php),

<code>    public static function pop($queue)
    {
        $item = self::redis()->lpop('queue:' . $queue);
        if(!$item) {
            return;
        }

        $result = json_decode($item, true);
        if(!is_array($result)) error_log('why not array : ' . $item);
        return $result;        
    }</code>

php日志中一天会出现过几次why not array ..,输出的$item不是有效的json

哪位兄弟有经验的,给点思路?给点建议?

回复内容:

Resque::enqueue存数据放到redis队列,worker拿出来json_decode有时是不完整的(访问量大的时候出现几率可能更高,没完全验证)!
郁闷极至。通读了多编php-ressue代码,也很清晰,看不出啥问题啊。 php-ressue中打log如下(Rescue.php),

<code>    public static function pop($queue)
    {
        $item = self::redis()->lpop('queue:' . $queue);
        if(!$item) {
            return;
        }

        $result = json_decode($item, true);
        if(!is_array($result)) error_log('why not array : ' . $item);
        return $result;        
    }</code>

php日志中一天会出现过几次why not array ..,输出的$item不是有效的json

哪位兄弟有经验的,给点思路?给点建议?

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。