class Redis_Bingfa
{
function __construct()
{
$this->Config=new Config();
$redisinfo=$this->Config->get('redis');
$this->redis=new Redis();
$this->redis->connect($redisinfo['host'],$redisinfo['port']);
}
public function test_subscribe(){
$this->redis->setOption(Redis::OPT_READ_TIMEOUT,-1);
ini_set('default_socket_timeout', -1);
$this->redis->subscribe(array('redischat'),array($this,'process_msg'));
}
public function process_msg($redis,$chan,$msg){
echo $chan."|".$msg."\n";
}
public function test_publish(){
for($i=0;$i<10;$i++){
$this->redis->publish('redischat','user'.$i.' is bidding,price is:'.(7000+$i*200));
}
}
}
$redisBingfa =new Redis_Bingfa();
$action=$_GET['action'];
switch($action){
case 'test_subscribe':
$redisBingfa->test_publish();
$redisBingfa->test_subscribe();
break;
}