public function BackendChain::get

Implements Drupal\Core\Cache\CacheBackendInterface::get().

Overrides CacheBackendInterface::get

File

drupal/core/lib/Drupal/Core/Cache/BackendChain.php, line 75
Definition of Drupal\Core\Cache\BackendChain.

Class

BackendChain
Defines a chained cache implementation for combining multiple cache backends.

Namespace

Drupal\Core\Cache

Code

public function get($cid, $allow_invalid = FALSE) {
  foreach ($this->backends as $index => $backend) {
    if (($return = $backend
      ->get($cid, $allow_invalid)) !== FALSE) {

      // We found a result, propagate it to all missed backends.
      if ($index > 0) {
        for ($i = $index - 1; 0 <= $i; --$i) {
          $this->backends[$i]
            ->set($cid, $return->data, $return->expire, $return->tags);
        }
      }
      return $return;
    }
  }
  return FALSE;
}