diff --git a/src/Driver/RedisProxyListDriver.php b/src/Driver/RedisProxyListDriver.php index 9774dbd..956f062 100644 --- a/src/Driver/RedisProxyListDriver.php +++ b/src/Driver/RedisProxyListDriver.php @@ -84,20 +84,16 @@ public function wait(Closure $callback, array $priorities = []): void continue; } $key = $this->getKey($priority); - $length = $this->getLength($key); - if ($length === 0) { - continue; - } $foundPriority = $priority; - for ($i = 0; $i < $length; $i++) { + while (true) { $messageString = $this->pop($key); - - if ($messageString !== null) { - $this->ping(HermesProcess::STATUS_PROCESSING); - $message = $this->serializer->unserialize($messageString); - $callback($message, $foundPriority); - $this->incrementProcessedItems(); + if ($messageString === null) { + break; } + $this->ping(HermesProcess::STATUS_PROCESSING); + $message = $this->serializer->unserialize($messageString); + $callback($message, $foundPriority); + $this->incrementProcessedItems(); } } @@ -133,12 +129,4 @@ private function pop(string $key): ?string return null; } - - /** - * @throws RedisProxyException - */ - private function getLength(string $key): int - { - return $this->redis->llen($key); - } }