Example 1, the queue operation:
Copy CodeThe code is as follows:
$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 ";
}
}
?>
Example 2, the operation of the team:
Copy the Code code as follows:
$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);
}
?>
http://www.bkjia.com/PHPjc/326633.html www.bkjia.com true http://www.bkjia.com/PHPjc/326633.html techarticle Example 1, the queue operation: Copy code code as follows: PHP $redis = new Redis (), $redis-connect (' 127.0.0.1 ', 6379), while (True) {try{$value = ' value_ '. D Ate (' y-m-d h:i:s '); $redis-lpush ...