Skip to content

Commit

Permalink
Do not call llen for RedisProxyListDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
lulco committed Oct 21, 2024
1 parent 0be5906 commit 5a92c2d
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/Driver/RedisProxyListDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 5a92c2d

Please sign in to comment.