简单redis队列实现

入队列操作文件 list_push.php

<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
while (true) {
    $redis->lPush('list1', 'A_'.date('Y-m-d H:i:s'));
    sleep(rand()%3);
}
?>

执行# php list_push.php &

出队列操作 list_pop.php文件
<?php
$redis = new Redis();
$redis->pconnect('127.0.0.1', 6379);
while(true) {
    try {
        var_export( $redis->blPop('list1', 10) );
    } catch(Exception $e) {
        //echo $e;   
    }
}





原文地址:https://www.cnblogs.com/firmy/p/2304270.html