public function testQueueNoArgs() { Queue::put('MyJob'); Queue::put('MyJob'); Queue::put('MyJob'); $sql = "select count(*) from queue"; $this->assertEquals(3, $this->_db->getOne($sql)); $this->assertTrue(Queue::consume('MyJob')); $this->assertTrue(Queue::consume('MyJob')); $this->assertTrue(Queue::consume('MyJob')); $sql = "select count(*) from queue"; $this->assertEquals(0, $this->_db->getOne($sql)); $this->assertNull(Queue::consume('MyJob')); }
//实例化Memcache $mc = new Memcache(); $mc->connect('127.0.0.1', 11211); //实例化消息队列 $queue = new Queue($mc); $name = "Memcache"; //写入消息队列 $queue->put($name, "Memcache消息队列测试--" . rand(0, 100)); //出消息队列 $temp = $queue->get($name); var_dump($temp); $temp = $queue->status($name); var_dump($temp); echo "<hr/>"; /*******Tokyotrant*******/ echo "Tokyotrant队列测试:<br />"; //实例化Tokyotran $tt = new Memcache(); $tt->connect('127.0.0.1', 1978); //实例化消息队列 $queue = new Queue($tt); $name = "Tokyotrant"; //写入消息队列 $queue->put($name, "Tokyotrant消息队列测试--" . rand(0, 100)); //出消息队列 $temp = $queue->get($name); var_dump($temp); $temp = $queue->status($name); var_dump($temp); echo "<hr/>"; /*******Redis*******/