Use the redis queue to operate the instance code in php. Example 1: Team-up operation: Copy the code as follows :? Php $ redisnewRedis (); $ redis-connect (127.0.0.1, 6379); while (True) {try {$ valuevalue _. date (Y-m-dH: I: s); $ redis-LPUSH example 1, queuing operation:
The code is as follows:
$ Redis = new Redis ();
$ Redis-> connect ('2017. 0.0.1 ', 127 );
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 ";
}
}
?>
Example 2: Team-out operations:
The code is as follows:
$ Redis = new Redis ();
$ Redis-> pconnect ('2017. 0.0.1 ', 127 );
While (True ){
Try {
Echo $ redis-> LPOP ('key1'). "\ n ";
} Catch (Exception $ e ){
Echo $ e-> getMessage (). "\ n ";
}
Sleep (rand () % 3 );
}
?>
The pipeline code is as follows :? Php $ redis = new Redis (); $ redis-connect ('2017. 0.0.1 ', 6379); while (True) {try {$ value = 'value _'. date ('Y-m-d H: I: s'); $ redis-LPUSH...