From b79aa1b195e3755ccf211894ea3ae8c14ad40913 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 11 Nov 2025 15:41:05 +0100 Subject: [PATCH] refactor(CleanupRedis): optimize key retrieval in cleanupStuckJobs using Redis scan --- app/Console/Commands/CleanupRedis.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/CleanupRedis.php b/app/Console/Commands/CleanupRedis.php index 64a3ac259..93035e255 100644 --- a/app/Console/Commands/CleanupRedis.php +++ b/app/Console/Commands/CleanupRedis.php @@ -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);