From 6d9ea6584dc866d1be735c2c07be26cdb21d9306 Mon Sep 17 00:00:00 2001 From: LukasRos Date: Mon, 11 Nov 2024 00:02:02 +0100 Subject: [PATCH] Fixed cache key issue --- CloudObjects/SDK/ObjectRetriever.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CloudObjects/SDK/ObjectRetriever.php b/CloudObjects/SDK/ObjectRetriever.php index 29b18a0..6b4cfd5 100644 --- a/CloudObjects/SDK/ObjectRetriever.php +++ b/CloudObjects/SDK/ObjectRetriever.php @@ -112,14 +112,18 @@ class ObjectRetriever implements CustomCacheAndLogInterface { $this->logger->info($message, [ 'elapsed_ms' => round((microtime(true) - $ts) * 1000) ]); } + private function getCacheKey($id) { + return $this->options['cache_prefix'].$this->options['auth_ns'].'/'.$id; + } + private function getFromCache($id) { - return (isset($this->cache) && $this->cache->contains($this->options['cache_prefix'].$id)) - ? $this->cache->fetch($this->options['cache_prefix'].$this->options['auth_ns'].'/'.$id) : null; + return (isset($this->cache) && $this->cache->contains($this->getCacheKey($id))) + ? $this->cache->fetch($this->getCacheKey($id)) : null; } private function putIntoCache($id, $data, $ttl) { if (isset($this->cache)) - $this->cache->save($this->options['cache_prefix'].$this->options['auth_ns'].'/'.$id, $data, $ttl); + $this->cache->save($this->getCacheKey($id), $data, $ttl); } public function getFromCacheCustom($id) {