redis 队列操作&php

入队操作

    $redis = new Redis();

    $redis->connect('127.0.0.1',6379);

    for(i=0;i<10;$i++){

        try{
        	$redis->LPUSH("aaa",rand(10000,50000));
        }catch(Exception $e){
    	    echo $e->getMassage();
        }

    }

出队操作

    $redis = new Redis();

    $redis->connect('127.0.0.1',6379);

    while(true){
	    try{
		    $v = $redis->LPOP('aaa');
		    if(!$v){
			    break;
		    }
		    echo $v."<br/>";
	    }catch(Exception $e){
		    echo $e->getMassage();
	    }
    }
posted @ 2018-11-06 17:13  莫名______Q  阅读(94)  评论(0)    收藏  举报