Skip to content

Commit 3d5b97d

Browse files
committed
refactor RedisHandler::deleteMatching()
1 parent 9099e20 commit 3d5b97d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

system/Cache/Handlers/RedisHandler.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,17 @@ public function delete(string $key)
175175
*/
176176
public function deleteMatching(string $pattern)
177177
{
178+
/** @var list<string> $matchedKeys */
178179
$matchedKeys = [];
179180
$pattern = static::validateKey($pattern, $this->prefix);
180181
$iterator = null;
181182

182183
do {
183-
// Scan for some keys
184+
/** @var false|list<string>|Redis $keys */
184185
$keys = $this->redis->scan($iterator, $pattern);
185186

186-
// Redis may return empty results, so protect against that
187-
if ($keys !== false) {
188-
foreach ($keys as $key) {
189-
$matchedKeys[] = $key;
190-
}
187+
if (is_array($keys)) {
188+
$matchedKeys = [...$matchedKeys, ...$keys];
191189
}
192190
} while ($iterator > 0);
193191

0 commit comments

Comments
 (0)