You are here

private function FileQueue::bufferInitialize in Purge 8.3

Initialize the buffer.

Overrides MemoryQueue::bufferInitialize

1 call to FileQueue::bufferInitialize()
FileQueue::__construct in src/Plugin/Purge/Queue/FileQueue.php
Construct a FileQueue object.

File

src/Plugin/Purge/Queue/FileQueue.php, line 50

Class

FileQueue
A \Drupal\purge\Plugin\Purge\Queue\QueueInterface compliant file-based queue.

Namespace

Drupal\purge\Plugin\Purge\Queue

Code

private function bufferInitialize() {
  if (!$this->bufferInitialized) {
    $this->bufferInitialized = TRUE;
    $this->buffer = [];

    // Open and parse the queue file, if it wasn't there during initialization
    // it will automatically get written at some point.
    if (file_exists($this->file)) {
      foreach (file($this->file) as $line) {
        $line = explode(self::SEPARATOR, str_replace("\n", '', $line));
        $item_id = (int) array_shift($line);
        $line[self::EXPIRE] = (int) $line[self::EXPIRE];
        $line[self::CREATED] = (int) $line[self::CREATED];
        $this->buffer[$item_id] = $line;
      }
    }
  }
}