You are here

protected function CoordinatedWriteCounterTrait::getLastWrite in Supercache 2.0.x

Same name and namespace in other branches
  1. 8 src/Cache/CoordinatedWriteCounterTrait.php \Drupal\supercache\Cache\CoordinatedWriteCounterTrait::getLastWrite()

Items retrieve from the persistent backend that have been modified prior to this timestamp are to be considered outdated.

3 calls to CoordinatedWriteCounterTrait::getLastWrite()
ChainedFastBackend::getMultiple in src/Cache/ChainedFastBackend.php
Returns data from the persistent cache when given an array of cache IDs.
CoordinatedWriteCounterTrait::clearFastStorageIfInvalid in src/Cache/CoordinatedWriteCounterTrait.php
Some storage backends cannot rely on the information provided by $this->getLastWrite() to tell what items they should invalidate. Calling this method will clear all of the fast backend if it is considered not to be consistent with the contents of…
CoordinatedWriteCounterTrait::markAsOutdated in src/Cache/CoordinatedWriteCounterTrait.php
Notify that a write has happened, it does not inmediately invalidate the persistent storage.

File

src/Cache/CoordinatedWriteCounterTrait.php, line 120

Class

CoordinatedWriteCounterTrait
Used by components to coordinate invalidations between a volatile and a persistent storage.

Namespace

Drupal\supercache\Cache

Code

protected function getLastWrite() {
  if ($this->lastWrite === NULL) {
    $cache = $this
      ->getPersistentStorage($this->writeKey);
    if ($cache && $cache->data['head'] != $this
      ->getHeadId()) {

      // Someone that was not us did the last write, so take
      // their timestamp.
      $this->lastWrite = $cache->data['timestamp'];
      if ($cache = $this
        ->getFastStorage($this->writeKey)) {
        if ($this->lastWrite != $cache->data) {
          $this
            ->setFastStorage($this->writeKey, $this->lastWrite);
          $this->fastStorageInvalid = TRUE;
        }
      }
    }
    else {

      // If we are here this means that either the binary has never been invalidated,
      // or that the last invalidation was actually made by ourselves so we retain
      // the previous invalidation timestamp that we had.
      $current = $cache && $cache->data['head'] == $this
        ->getHeadId() ? $cache->data['timestamp'] : 0;
      $cache = $this
        ->getFastStorage($this->writeKey);
      $this->lastWrite = $cache && !empty($cache->data) ? $cache->data : $current;
      $this->fastStorageInvalid = FALSE;
    }
  }
  return $this->lastWrite;
}