Changeset 2501


Ignore:
Timestamp:
Nov 23, 2011, 12:40:58 AM (8 years ago)
Author:
goya
Message:

Ajout d'un optimize tout les 1000 commits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/lib/model/solr/SolrConnector.class.php

    r2499 r2501  
    55  private $solr = NULL;
    66  private $_options = NULL;
     7  private $nb_commit = 0;
    78
    89  protected function doLog($message, $priority)
     
    4546  }
    4647
     48  public function commit() {
     49        $optimize = false;
     50        $wait = false;
     51        $this->nb_commit++;
     52        if ($this->nb_commit > 1000) {
     53                $optimize = true;
     54                $wait = true;
     55                $this->nb_commit = 0;
     56        }
     57        return $this->solr->commit($optimize, $wait);
     58  }
    4759
    4860  public function deleteLuceneRecord($solr_id)
    4961  {
    5062    if($this->solr->deleteById($solr_id) ) {
    51       return $this->solr->commit();
     63      return $this->commit();
    5264    }
    5365    return false;
     
    7486     }
    7587     $this->solr->addDocument($document);
    76      $this->solr->commit();
     88     $this->commit();
    7789  }
    7890
    7991  public function deleteAll() {
    8092    $this->solr->deleteByQuery('*:*');
    81     $this->solr->commit();
     93    $this->commit();
    8294  }
    8395
Note: See TracChangeset for help on using the changeset viewer.