Clean the search cache based on the index

@param string|StorageMeta|null $meta
346363
protected function clean( $meta = null ) {

    //
    if( $meta && !( $meta instanceof StorageMeta ) ) {
      $meta = $this->getMeta( $meta );
    }

    // clear the cache
    if( !$meta || empty( $meta->token ) ) $this->cache = [];
    else foreach( $this->cache as $i => $_ ) {

      if( empty( $i ) || $i == $meta->token[ 0 ] || strpos( $i, $meta->token[ 0 ] ) === 0 ) {
        unset( $this->cache[ $i ] );
      }
    }
  }
1218495
public function removeMeta(PostMeta $meta)
    {
        if ($this->metas->contains($meta)) {
            $this->metas->remove($meta);
        }

        return $this;
    }
1271633
public function clean($group = null)
	{
		$hash = $this->options['hash'];

		$index = $this->engine->get($hash . '-index');
		if ($index === false)
		{
			$index = array();
		}

		foreach ($index as $key => $value)
		{
			if (strpos($value->name, $hash . '-cache-' . $group . '-') === 0) // xor $mode != 'group')
			{
				$this->engine->delete($value->name, 0);
				unset($index[$key]);
			}
		}

		$this->engine->replace($hash . '-index', $index, 0);
	}
507042
function cleanup()
    {
        $this->HTTP->removeSessionVariable( $this->StorageName . $this->MetaDataName );
        $this->HTTP->removeSessionVariable( $this->StorageName . $this->VariableListName );
        $this->MetaData = array();
        $this->VariableList = array();
    }
371005
private function _cleanCache()
    {
        if ($this->cache instanceof \Zend_Cache_Core) {
            $this->cache->clean();
            $this->addMessage($this->_('Cache cleaned'));
        }
    }
394041
public static function setMetas(array $metas, bool $replace_existing=false) :void {
		// if we want to purge existing metas
		!$replace_existing ?: self::$_metas = [];
		// name is the key for storing metas
		self::$_metas += $metas;
	}
638828
public function getMeta($metaKey)
    {
        /** @var Collection $matchingMeta */
        $matchingMeta = $this->meta->filter(
            function (Meta $meta) use ($metaKey) {
                return $meta->getKey() == $metaKey;
            }
        );

        return $matchingMeta->count() == 1 ? $matchingMeta->first()->getValue() : null;
    }
772989
public function delete( $key, $user_id = null, $meta_value = '' ) {
		if ( ! isset( $user_id ) ) {
			$user_id = $this->user_id;
		}
		if ( $user_id <= 0 ) {
			return false;
		}

		return delete_user_meta( $user_id, $this->get_meta_key( $key ), $meta_value );
	}
270138
private void refreshMetadataCache(final Queue<WindupMetadataSystem> metadataSystemCache, final DecompilerSettings settings)
    {
        metadataSystemCache.clear();
        for (int i = 0; i < this.getNumberOfThreads(); i++)
        {
            metadataSystemCache.add(new NoRetryMetadataSystem(settings.getTypeLoader()));
        }
    }
780195
public function delete($file)
	{
		$metaFile = $this->getMetaFilePath($file);
		if ($this->fs->exists($metaFile))
			$this->fs->delete($metaFile);
		if ($this->f3->get('CACHE')) {
			$cache = \Cache::instance();
			if ($cache->exists($cacheHash = $this->getCacheHash($file)))
				$cache->clear($cacheHash);
		}
	}
616083
public function retrieveAll($meta = false) {
    if ($meta === false) {
      $results = array();
      $cachedData = $this->_loadCache();
      if ($cachedData) {
        foreach ($cachedData as $k => $v) {
          $results[$k] = unserialize($v['data']);
        }
      }
      return $results;
    } else {
      return $this->_loadCache();
    }
  }
267708
public function removeMeta($key)
    {
        $metadata = new ArrayCollection($this->metadata);
        $removed = $metadata->remove($key);
        $this->metadata = $metadata->toArray();

        return $removed;
    }
758518
public function removeMeta(\Sulu\Bundle\MediaBundle\Entity\FileVersionMeta $meta)
    {
        $this->meta->removeElement($meta);
    }
832074
public function metaData($key = null)
    {
        if (!$this->resource) {
            return null;
        }

        if (!$meta = stream_get_meta_data($this->resource)) {
            return null;
        }

        if (!$key) {
            return $meta;
        }

        return isset($meta[$key]) ? $meta[$key] : null;
    }
368433
public static function clear_static() {

        static::$enabledsearchareas = null;
        static::$allsearchareas = null;
        static::$instance = null;
        static::$searchareacategories = null;

        base_block::clear_static();
        engine::clear_users_cache();
    }
552447
public function filter($table)
    {
        $this->enableRecursive(true);

        foreach ($table->getRows() as $row) {
            $row->deleteMetadata($this->metadataToRemove);

            $this->filterSubTable($row);
        }
    }
147055
public function get($meta)
  {
    return isset($this->parsed[$meta]) ? $this->parsed[$meta] : null;
  }