File tree Expand file tree Collapse file tree
Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Eel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ class ElasticSearchQuery implements QueryInterface
2525 */
2626 protected $ queryBuilder ;
2727
28+ /**
29+ * @var array
30+ */
31+ protected static $ runtimeQueryResultCache ;
32+
2833 public function __construct (ElasticSearchQueryBuilder $ elasticSearchQueryBuilder )
2934 {
3035 $ this ->queryBuilder = $ elasticSearchQueryBuilder ;
@@ -35,7 +40,13 @@ public function __construct(ElasticSearchQueryBuilder $elasticSearchQueryBuilder
3540 */
3641 public function execute ($ cacheResult = false )
3742 {
38- return new ElasticSearchQueryResult ($ this );
43+ $ queryHash = md5 (json_encode ($ this ->queryBuilder ->getRequest ()));
44+ if ($ cacheResult === true && isset (self ::$ runtimeQueryResultCache [$ queryHash ])) {
45+ return self ::$ runtimeQueryResultCache [$ queryHash ];
46+ }
47+ $ queryResult = new ElasticSearchQueryResult ($ this );
48+ self ::$ runtimeQueryResultCache [$ queryHash ] = $ queryResult ;
49+ return $ queryResult ;
3950 }
4051
4152 /**
Original file line number Diff line number Diff line change @@ -671,7 +671,7 @@ public function fetch()
671671 public function execute ()
672672 {
673673 $ elasticSearchQuery = new ElasticSearchQuery ($ this );
674- $ result = $ elasticSearchQuery ->execute ();
674+ $ result = $ elasticSearchQuery ->execute (true );
675675 return $ result ;
676676 }
677677
You can’t perform that action at this time.
0 commit comments