refactor(CleanupRedis): optimize key retrieval in cleanupStuckJobs using Redis scan
This commit is contained in:
parent
a95e92f098
commit
b79aa1b195
1 changed files with 7 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue