refactor(CleanupRedis): optimize key retrieval in cleanupStuckJobs using Redis scan

This commit is contained in:
Andras Bacsai 2025-11-11 15:41:05 +01:00
parent a95e92f098
commit b79aa1b195

View file

@ -356,7 +356,13 @@ private function cleanupStuckJobs($redis, string $prefix, bool $dryRun, bool $is
$now = time();
// Get all keys with the horizon prefix
$keys = $redis->keys('*');
$cursor = 0;
$keys = [];
do {
$result = $redis->scan($cursor, ['MATCH' => '*', 'COUNT' => 100]);
$cursor = $result[0];
$keys = array_merge($keys, $result[1]);
} while ($cursor !== 0);
foreach ($keys as $key) {
$keyWithoutPrefix = str_replace($prefix, '', $key);