Home > php教程 > php手册 > redis---队列操作的例子(php)

redis---队列操作的例子(php)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:48:31
Original
1375 people have browsed it

入队操作

01

02 $redis = new Redis();

03 $redis->connect('127.0.0.1',6379);

04 while(True){

05     try{

06         $value = 'value_'.date('Y-m-d H:i:s');

07         $redis->LPUSH('key1',$value);

08         sleep(rand()%3);

09         echo $value."\n";

10     }catch(Exception $e){

11         echo $e->getMessage()."\n";

12     }

13 }

14 ?>

 

出队操作

01

02 $redis = new Redis();

03 $redis->pconnect('127.0.0.1',6379);

04 while(True){

05     try{

06         echo $redis->LPOP('key1')."\n";

07     }catch(Exception $e){

08         echo $e->getMessage()."\n";

09     }

10     sleep(rand()%3);

11
 }?>
 

 

摘自  zhuangge
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php redis connection problem
From 1970-01-01 08:00:00
0
0
0
About a small error in the redis manual
From 1970-01-01 08:00:00
0
0
0
python2.7 - django cannot connect to redis
From 1970-01-01 08:00:00
0
0
0
I can't connect to redis using php
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template