首页 >后端开发 >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