public function DatabaseBackend::getMultiple

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

Overrides CacheBackendInterface::getMultiple

1 call to DatabaseBackend::getMultiple()

File

drupal/core/lib/Drupal/Core/Cache/DatabaseBackend.php, line 65
Definition of Drupal\Core\Cache\DatabaseBackend.

Class

DatabaseBackend
Defines a default cache implementation.

Namespace

Drupal\Core\Cache

Code

public function getMultiple(&$cids, $allow_invalid = FALSE) {

  // When serving cached pages, the overhead of using ::select() was found
  // to add around 30% overhead to the request. Since $this->bin is a
  // variable, this means the call to ::query() here uses a concatenated
  // string. This is highly discouraged under any other circumstances, and
  // is used here only due to the performance overhead we would incur
  // otherwise. When serving an uncached page, the overhead of using
  // ::select() is a much smaller proportion of the request.
  $result = array();
  try {
    $result = $this->connection
      ->query('SELECT cid, data, created, expire, serialized, tags, checksum_invalidations, checksum_deletions FROM {' . $this->connection
      ->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(
      ':cids' => $cids,
    ));
  } catch (\Exception $e) {

    // Nothing to do.
  }
  $cache = array();
  foreach ($result as $item) {
    $item = $this
      ->prepareItem($item, $allow_invalid);
    if ($item) {
      $cache[$item->cid] = $item;
    }
  }
  $cids = array_diff($cids, array_keys($cache));
  return $cache;
}