From b8e15b42fa269646dcda140a0a139b4022a67de7 Mon Sep 17 00:00:00 2001 From: Art4 Date: Tue, 19 Nov 2024 08:04:06 +0000 Subject: [PATCH] Refactor DatabaseCache --- src/Core/Cache/Type/DatabaseCache.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Core/Cache/Type/DatabaseCache.php b/src/Core/Cache/Type/DatabaseCache.php index 629472535a..efb9a8d03e 100644 --- a/src/Core/Cache/Type/DatabaseCache.php +++ b/src/Core/Cache/Type/DatabaseCache.php @@ -47,17 +47,21 @@ class DatabaseCache extends AbstractCache implements ICanCache } $stmt = $this->dba->select('cache', ['k'], $where); + } catch (\Exception $exception) { + throw new CachePersistenceException(sprintf('Cannot fetch all keys with prefix %s', $prefix), $exception); + } + try { $keys = []; while ($key = $this->dba->fetch($stmt)) { array_push($keys, $key['k']); } } catch (\Exception $exception) { - throw new CachePersistenceException(sprintf('Cannot fetch all keys with prefix %s', $prefix), $exception); - } finally { $this->dba->close($stmt); + throw new CachePersistenceException(sprintf('Cannot fetch all keys with prefix %s', $prefix), $exception); } + $this->dba->close($stmt); return $keys; }