mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-20 02:17:09 +00:00
refactor(CleanupRedis): optimize key retrieval in cleanupStuckJobs using Redis scan
This commit is contained in:
1 parent
a95e92f098
commit
b79aa1b195
1 file changed
+7
-1
@@ -356,7 +356,13 @@ class CleanupRedis extends Command
|
|||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
// Get all keys with the horizon prefix
|
// 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) {
|
foreach ($keys as $key) {
|
||||||
$keyWithoutPrefix = str_replace($prefix, '', $key);
|
$keyWithoutPrefix = str_replace($prefix, '', $key);
|
||||||
|
|||||||
Reference in new issue
Block a user