function BackendChain::get

Same name in other branches
  1. 9 core/lib/Drupal/Core/Cache/BackendChain.php \Drupal\Core\Cache\BackendChain::get()
  2. 10 core/lib/Drupal/Core/Cache/BackendChain.php \Drupal\Core\Cache\BackendChain::get()
  3. 11.x core/lib/Drupal/Core/Cache/BackendChain.php \Drupal\Core\Cache\BackendChain::get()

Overrides CacheBackendInterface::get

File

core/lib/Drupal/Core/Cache/BackendChain.php, line 80

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.