From d219306f2227c25ade8c9561de61167826cba199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Gajd=C5=AF=C5=A1ek?= Date: Wed, 15 Jan 2025 16:36:12 +0100 Subject: [PATCH] Improve GraphQL caching for large queries Pimcore limits caching to a maximum of 50 items per request. For large GraphQL queries, this limit can easily be exceeded because every object loaded during query resolution is added to the cache queue with priority 0. When the queue is truncated, only the top 50 items (by priority) are retained. This commit increases the priority of the final GraphQL query result, ensuring this is more likely to be cached despite the 50-item limit. --- src/Service/OutputCacheService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Service/OutputCacheService.php b/src/Service/OutputCacheService.php index 15d42aca..68873c3e 100644 --- a/src/Service/OutputCacheService.php +++ b/src/Service/OutputCacheService.php @@ -111,7 +111,9 @@ protected function loadFromCache($key) */ protected function saveToCache($key, $item, $tags = []): void { - \Pimcore\Cache::save($item, $key, $tags, $this->lifetime); + # Increase priority to 1 to make it less likely this cache item is evicted from the + # queue before actually being written + \Pimcore\Cache::save($item, $key, $tags, $this->lifetime, 1); } private function computeKey(Request $request): string