creates/refreshes a search cache query.

@param string $sKey   - key identifying the search
@param string $sQuery

@return TdbShopSearchCache
487392
public static function &CreateSearchCache($sKey, $sQuery, $sSearchTerm, $aSearchTerms = null, $aFilter = array())
    {
        $sShopId = null;
        $oShop = TdbShop::GetInstance();
        if ($oShop) {
            $sShopId = $oShop->id;
        }
        $oItem = self::GetSearchCacheItem($sKey, $sShopId);

        if (null === $oItem) {
            $oItem = TdbShopSearchCache::GetNewInstance();
            $aData = array('shop_id' => $oShop->id, 'searchkey' => $sKey, 'last_used_date' => date('Y-m-d H:i:s'), 'number_of_records_found' => -1);
            $oItem->LoadFromRow($aData);
            $oItem->AllowEditByAll(true);
            $oItem->Save();
            //die(0);
            $sTmpQuery = "SELECT MD5(CONCAT('".MySqlLegacySupport::getInstance()->real_escape_string($oItem->id)."-',tmpres.shop_article_id)) AS shop_search_cache_item_id,
        '".MySqlLegacySupport::getInstance()->real_escape_string($oItem->id)."' AS shop_search_cache_id, sum(tmpres.cms_search_weight) As cms_search_weight, tmpres.shop_article_id AS id from (".$sQuery.') AS tmpres group by tmpres.shop_article_id';
            if (TdbShopSearchIndexer::searchWithAND()) {
                $aTerms = TdbShopSearchIndexer::PrepareSearchWords($sSearchTerm, true);
                $sTmpQuery .= ' HAVING SUM(tmpres.wordhit) >= '.count($aTerms);
            }
            $sTmpQuery = $oItem->ProcessSearchQueryBeforeInsert($sTmpQuery);

            $query = "INSERT INTO `shop_search_cache_item` (`id`,`shop_search_cache_id`,`weight`, `shop_article_id`) {$sTmpQuery}";
            MySqlLegacySupport::getInstance()->query($query);
            $oItem->sqlData['number_of_records_found'] = MySqlLegacySupport::getInstance()->affected_rows();
            $oItem->fieldNumberOfRecordsFound = $oItem->sqlData['number_of_records_found'];
            $oItem->AllowEditByAll(true);
            $oItem->SaveFieldsFast(array('number_of_records_found' => $oItem->fieldNumberOfRecordsFound));
        } else {
            $aData = $oItem->sqlData;
            $aData['last_used_date'] = date('Y-m-d H:i:s');
            $oItem->LoadFromRow($aData);
            $oItem->AllowEditByAll(true);
            $oItem->SaveFieldsFast(array('last_used_date' => $aData['last_used_date']));
        }

        $oItem->sSearchTerm = $sSearchTerm;
        if (true === CMS_SHOP_SEARCH_ENABLE_SPELLCHECKER) {
            $oSpellCheck = &TCMSSpellcheck::GetInstance();
            $oSearchCacheObject = TdbShopSearchCache::GetNewInstance();
            $aCorrections = false;
            if (!empty($sSearchTerm)) {
                $aCorrections = $oSpellCheck->SuggestCorrection($oItem->sSearchTerm, array($oSearchCacheObject, 'GetBestSuggestion'));
            }
            if ($aCorrections) {
                $oItem->sSearchTermSpellChecked = $aCorrections['string'];
                $oItem->sSearchTermSpellCheckedFormated = $oItem->sSearchTerm;
                foreach ($aCorrections['corrections'] as $sOrg => $sCorrection) {
                    $oItem->sSearchTermSpellCheckedFormated = str_replace($sOrg, '<span class="correction">'.$sCorrection.'</span>', $oItem->sSearchTermSpellCheckedFormated);
                }
            } else {
                $oItem->sSearchTermSpellChecked = null;
                $oItem->sSearchTermSpellCheckedFormated = null;
            }
        }

        $oItem->aSearchTerms = $aSearchTerms;
        $oItem->aFilter = $aFilter;
        $oShop->SetActiveSearchCacheObject($oItem);

        return $oItem;
    }
140635
protected function _query(string $sQuery, array $aParam = [], bool $bExec) {

		if (empty($sQuery)) {
			throw new TangoException('empty $sQuery', 3);
		}

		$this->_connect();
		$this->_iErrorLast = NULL;

		try {
			return $this->_queryTry($sQuery, $aParam, $bExec);
		} catch(\PDOException $e) {
			if (!$this->_parseException($e->getCode())) {
				throw $e;
			}
		}
		return $this->_queryTry($sQuery, $aParam, $bExec);
	}
1324345
public function prepare($sQuery)
    {
        if (empty($this->oDb)) {
            $this->connect();
        }

        return $this->oDb->prepare($sQuery);
    }
648001
protected function _queryTry(string $sQuery, array $aParam = [], bool $bExec) {

		if ($aParam) {

			if ($this->_sPrevPrepareQuery === $sQuery) {
				$oResult = $this->_oPrevPrepare;
			} else {
				$this->_sPrevPrepareQuery = $sQuery;
				$aOption = [];
				if (key($aParam) !== 0) {
					$aOption[\PDO::ATTR_CURSOR] = \PDO::CURSOR_FWDONLY;
				}
				$oResult = $this->_oPDO->prepare($sQuery, $aOption);
				$this->_oPrevPrepare = $oResult;
			}

			@$oResult->execute($aParam);
			return $bExec ? $oResult->rowCount() : $oResult;
		}

		return $bExec ? @$this->_oPDO->exec($sQuery) : @$this->_oPDO->query($sQuery);
	}
1300732
public function addToList($sKey, $sValue)
    {
        if (empty($sKey) || empty($sValue)) {
            return;
        }

        //Get value from storage
        $arValueList = $this->getList($sKey);

        array_unshift($arValueList, $sValue);
        $arValueList = array_unique($arValueList);

        $this->put($sKey, $arValueList);
    }
772889
protected function unsetCache($sKey)
    {
        if (!static::$CACHING_ENABLED) {
            return false;
        } elseif (empty($sKey)) {
            return false;
        }

        $iCacheIndex = $this->getCache($sKey, false);
        if (is_null($iCacheIndex)) {
            return false;
        }

        unset($this->aCache[$iCacheIndex]);

        return true;
    }
1107507
protected function getCache($sKey, $bReturnValue = true)
    {
        if (!static::$CACHING_ENABLED) {
            return false;
        } elseif (empty($sKey)) {
            return false;
        }

        $sCacheKey = $this->getCachePrefix() . $sKey;
        foreach ($this->aCache as $iIndex => $oCacheItem) {
            if (in_array($sCacheKey, $oCacheItem->key)) {
                return $bReturnValue ? $oCacheItem->value : $iIndex;
            }
        }

        return null;
    }
501701
public static function clear($arTags, $sKeys = null)
    {
        $sCacheDriver = config('cache.default');
        if(!empty($arTags)) {
            if($sCacheDriver == 'redis') {
                if(!empty($sKeys)) {
                    Cache::tags($arTags)->forget($sKeys);
                } else {
                    Cache::tags($arTags)->flush();
                }
            } else {
                $sKeys = implode('_', $arTags).'_'.$sKeys;
                Cache::forget($sKeys);
            }
        }
    }
581960
public static function set(string $sKey, $mValue, int $iExpire = 86400) {
		return static::conn()->set($sKey, $mValue, $iExpire);
	}
641731
protected function getCache($cacheKey)
    {
        $cacheKey = 'combiner.'.$cacheKey;

        if (!Cache::has($cacheKey)) {
            return false;
        }

        return @unserialize(@base64_decode(Cache::get($cacheKey)));
    }
1283898
public function clear($sKey)
    {
        if (empty($sKey) || empty($this->arStore) || !isset($this->arStore[$sKey])) {
            return;
        }

        unset($this->arStore[$sKey]);
    }
604823
protected function getDefaultStorageValue($sKey, $sDefaultValue = null)
    {
        if (empty($this->obDefaultStorage)) {
            return $sDefaultValue;
        }

        return $this->obDefaultStorage->get($sKey, $sDefaultValue);
    }
879990
public static QueryCache getQueryCache(Cache<?, ?> cache) {
      return SecurityActions.getCacheGlobalComponentRegistry(cache.getAdvancedCache()).getComponent(QueryCache.class);
   }
754487
protected function updateMap(array &$aMap, string $sKey, array $aValues): self
    {
        if (!array_key_exists($sKey, $aMap)) {
            $aMap[$sKey] = [];
        }

        $aMap[$sKey] = array_values(
            array_unique(
                array_merge(
                    $aMap[$sKey],
                    $aValues
                )
            )
        );

        return $this;
    }
602355
public function delete(string $sKey): bool
    {
        if (array_key_exists($sKey, $this->aCookies) && setcookie($sKey, '', 1)) {
            unset($this->aCookies[$sKey]);
            return true;
        }

        return false;
    }
1081225
private InternalQueryCache createUnderlyingQueryCache(QueryCacheConfig queryCacheConfig,
                                                          QueryCacheRequest request,
                                                          String cacheId) {
        SubscriberContext subscriberContext = context.getSubscriberContext();
        QueryCacheFactory queryCacheFactory = subscriberContext.getQueryCacheFactory();
        request.withQueryCacheConfig(queryCacheConfig);
        return queryCacheFactory.create(request, cacheId);
    }
925089
protected function getSettingValue($sKey)
    {
        $arSettings = $this->settings;
        if (empty($sKey) || empty($arSettings) || !isset($arSettings[$sKey])) {
            return null;
        }

        return $arSettings[$sKey];
    }