You are here

protected function ReliablePredis::garbageCollection in Redis 8

Automatically release items, that have been claimed and exceeded lease time.

1 call to ReliablePredis::garbageCollection()
ReliablePredis::claimItem in src/Queue/ReliablePredis.php
Claims an item in the queue for processing.

File

src/Queue/ReliablePredis.php, line 144

Class

ReliablePredis
Redis queue implementation using Predis library backend.

Namespace

Drupal\redis\Queue

Code

protected function garbageCollection() {
  foreach ($this->client
    ->lrange($this->claimedListKey, 0, -1) as $qid) {
    if (!$this->client
      ->exists($this->leasedKeyPrefix . $qid)) {

      // The lease expired for this ID.
      $this->client
        ->lrem($this->claimedListKey, -1, $qid);
      $this->client
        ->lpush($this->availableListKey, $qid);
    }
  }
}