php redis 消息队列 一次出多少个队列
展开全部
方法如下:
[php] view plain copy print?
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
while(1){
try{
$value = "value_".time();
$redis->LPUSH('key1', $value);
echo $value."\n";
sleep(rand(1, 3));
}catch(Exception $e){
echo $e->getMessage(). "\n";
exit;
}
}
[php] view plain copy print?
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
while(1){
try{
$value = "value_".time();
$redis->LPUSH('key1', $value);
echo $value."\n";
sleep(rand(1, 3));
}catch(Exception $e){
echo $e->getMessage(). "\n";
exit;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询