searchService = $searchService; } /** * @param SearchRequestInterface $searchRequest * @return SearchResultInterface */ public function search(SearchRequestInterface $searchRequest): SearchResultInterface { $hash = $this->getHash($searchRequest); if (isset($this->results[$hash]) && $this->results[$hash] instanceof SearchResultInterface) { return $this->results[$hash]; } return $this->results[$hash] = $this->searchService->search($searchRequest); } /** * @param SearchRequestInterface $searchRequest * @return string */ protected function getHash(SearchRequestInterface $searchRequest): string { if (is_callable([$searchRequest, 'getRequestHash'])) { return (string)$searchRequest->getRequestHash(); } return sha1(serialize($searchRequest)); } }