Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-aloware committed Apr 14, 2023
1 parent 0dad937 commit a055b7e
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/Repositories/RedisRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ public function failedPartitionsWithCount($queue)
$queue,
'failedPartitionListPattern',
'extractPartitionNameFromFailedPartitionKey',
'failedPartitionKey',
'failedPartitionPerSecKey',
false
'failedPartitionKey'
);
}

Expand Down Expand Up @@ -938,23 +936,10 @@ private function popPrivate($queue, $partition, $partitionKeyResolver = 'partiti
$partitionKey = $this->$partitionKeyResolver($queue, $partition);

$processedKey = $this->partitionProcessedCountJobKey($queue, $partition);
$partitionPerSecKey = $this->partitionPerSecKey($queue, $partition);

$this->redis->incr($processedKey);
$this->redis->expire($processedKey, 3);

$now = time();
list ($lastAccess, $lastPersec) = explode(',', $this->redis->get($partitionPerSecKey) ?? ($now - 1) . ',0');

if ($now - $lastAccess >= 1) {
$persec = max($this->redis->get($processedKey) ?? 0, 0);

$data = $now . ',' . max($persec, $persec - $lastPersec);
$this->redis->set($partitionPerSecKey, $data, 'EX', 3);

$this->redis->decrBy($processedKey, $persec);
}

$result = $this->redis->multi()
->lpop($partitionKey)
->exists($partitionKey)
Expand Down

0 comments on commit a055b7e

Please sign in to comment.