You are here

public function DrupalMemcache::getMulti in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/src/DrupalMemcache.php \Drupal\memcache\DrupalMemcache::getMulti()

Retrieves multiple values from Memcache.

Parameters

array $keys: An array of keys for items to retrieve.

Return value

array An array of stored items, or FALSE otherwise.

Overrides DrupalMemcacheInterface::getMulti

File

modules/memcache/src/DrupalMemcache.php, line 75
Contains \Drupal\memcache\DrupalMemcache.

Class

DrupalMemcache
Class DrupalMemcache.

Namespace

Drupal\memcache

Code

public function getMulti(array $keys) {
  $full_keys = array();
  foreach ($keys as $cid) {
    $full_key = $this
      ->key($cid);
    $full_keys[$cid] = $full_key;
  }
  $track_errors = ini_set('track_errors', 1);
  $php_errormsg = '';
  $results = @$this->memcache
    ->get($full_keys);
  if (!empty($php_errormsg)) {
    register_shutdown_function('memcache_log_warning', LogLevel::WARNING, 'Exception caught in DrupalMemcache::getMulti: !msg', array(
      '!msg' => $php_errormsg,
    ));
    $php_errormsg = '';
  }
  ini_set('track_errors', $track_errors);

  // If $results is FALSE, convert it to an empty array.
  if (!$results) {
    $results = array();
  }

  // Convert the full keys back to the cid.
  $cid_results = array();
  $cid_lookup = array_flip($full_keys);
  foreach ($results as $key => $value) {
    $cid_results[$cid_lookup[$key]] = $value;
  }
  return $cid_results;
}