热门标签

php 实现 redis 队列 消息

入队列

<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$password = '123456';
$redis->auth($password);
$arr = array('h','e','l','l','o','w','o','r','l','d');
foreach($arr as $k=>$v){
  $redis->rpush("mylist",$v);
}

出队列

<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$password = '123456';
$redis->auth($password);
//list类型出队操作
$value = $redis->lpop('mylist');
if($value){
 echo "出队的值".$value;
}else{
  echo "出队完成";
}
?>

建立定时任务

*/1 * * * * root php /wwwroot/workplace/redis/index.php

 */3 * * * * root php /wwwroot/workplace/redis/demo.php

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

评论 (0)