cleanIndexCache() public method

Clean the cache by index identifier and store.
public cleanIndexCache ( string $indexIdentifier, string $storeId ) : void
$indexIdentifier string Index identifier.
$storeId string Store id.
return void
Beispiel #1
0
 /**
  * Create the synonyms index for a store id.
  *
  * @param integer  $storeId    Store id.
  * @param string[] $synonyms   Raw synonyms list.
  * @param string[] $expansions Raw expansions list.
  *
  * @return void
  */
 public function reindex($storeId, $synonyms, $expansions)
 {
     $indexIdentifier = ThesaurusIndex::INDEX_IDENTIER;
     $indexName = $this->indexSettingsHelper->createIndexNameFromIdentifier($indexIdentifier, $storeId);
     $indexAlias = $this->indexSettingsHelper->getIndexAliasFromIdentifier($indexIdentifier, $storeId);
     $indexSettings = ['settings' => $this->getIndexSettings($synonyms, $expansions)];
     $this->client->indices()->create(['index' => $indexName, 'body' => $indexSettings]);
     $this->indexManager->proceedIndexInstall($indexName, $indexAlias);
     $this->cacheHelper->cleanIndexCache(ThesaurusIndex::INDEX_IDENTIER, $storeId);
 }
 /**
  * {@inheritDoc}
  */
 public function saveIndex($dimensions, \Traversable $documents)
 {
     foreach ($dimensions as $dimension) {
         $storeId = $dimension->getValue();
         $index = $this->indexOperation->getIndexByName($this->indexName, $storeId);
         $type = $index->getType($this->typeName);
         foreach ($this->batch->getItems($documents, $this->batchSize) as $batchDocuments) {
             foreach ($type->getDatasources() as $datasource) {
                 $batchDocuments = $datasource->addData($storeId, $batchDocuments);
             }
             $bulk = $this->indexOperation->createBulk()->addDocuments($index, $type, $batchDocuments);
             $this->indexOperation->executeBulk($bulk);
         }
         $this->indexOperation->refreshIndex($index);
         $this->indexOperation->installIndex($index, $storeId);
         $this->cacheHelper->cleanIndexCache($this->indexName, $storeId);
     }
     return $this;
 }