首頁 >後端開發 >php教程 >redis 行列操作的例子(php)

redis 行列操作的例子(php)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-13 12:18:47900瀏覽

redis 队列操作的例子(php)

入队操作

<?php $redis = new Redis();$redis->connect('127.0.0.1',6379);while(True){  try{    $value = 'value_'.date('Y-m-d H:i:s');    $redis->LPUSH('key1',$value);    sleep(rand()%3);    echo $value."\n";  }catch(Exception $e){    echo $e->getMessage()."\n";  }}?>


出队操作

<?php $redis = new Redis();$redis->pconnect('127.0.0.1',6379);while(True){  try{    echo $redis->LPOP('key1')."\n";  }catch(Exception $e){  echo $e->getMessage()."\n";  }  sleep(rand()%3);}?>



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn