Refactor DatabaseCache

This commit is contained in:
Art4 2024-11-19 08:04:06 +00:00
parent 0f785e8bd0
commit b8e15b42fa

View 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;
}