Exemplo n.º 1
0
 public function testRebuild()
 {
     $search = $this->object->xs->search;
     $doc = new XSDocument(self::$data_gbk);
     $this->object->add($doc);
     $this->object->add($doc);
     $this->object->flushIndex();
     sleep(2);
     $this->assertEquals(2, $search->reopen(true)->dbTotal);
     $this->object->beginRebuild();
     $this->object->add($doc);
     $this->assertEquals(2, $search->reopen(true)->dbTotal);
     $this->object->endRebuild();
     $this->object->flushIndex();
     sleep(2);
     $this->assertEquals(1, $search->reopen(true)->dbTotal);
 }
Exemplo n.º 2
0
 /**
  * 析构函数
  * 在此自动关闭开启的 rebuild
  */
 public function __destruct()
 {
     if ($this->_rebuild === true) {
         try {
             $this->endRebuild();
         } catch (Exception $e) {
         }
     }
     foreach (self::$_adds as $srv) {
         $srv->close();
     }
     self::$_adds = array();
     parent::__destruct();
 }