]> git.mxchange.org Git - friendica.git/commitdiff
Refactor DatabaseCache
authorArt4 <art4@wlabs.de>
Tue, 19 Nov 2024 08:04:06 +0000 (08:04 +0000)
committerArt4 <art4@wlabs.de>
Tue, 19 Nov 2024 08:04:06 +0000 (08:04 +0000)
src/Core/Cache/Type/DatabaseCache.php

index 629472535acc0655c3460935f22b51e5a9b4153a..efb9a8d03ec51bd03d38f3d523f06f3892e682e5 100644 (file)
@@ -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;
        }