public function DrupalMemcached::getMulti in Memcache Storage 8
Get the multiple cache items from the memcached pool.
Parameters
array $keys: List of cache keys to receive.
string $cache_bin: Name of the cache bin.
Return value
array List of cached data with cache keys as array keys.
Overrides DrupalMemcachedInterface::getMulti
File
- src/
DrupalMemcached.php, line 148
Class
- DrupalMemcached
- Class DrupalMemcached
Namespace
Drupal\memcache_storageCode
public function getMulti(array $keys, $cache_bin = '') {
// No point in performing any action is we're not connected to memcached.
if (empty($this->isConnected)) {
return [];
}
// Format every cache key before the request to memcached pool.
$memcached_keys = [];
foreach ($keys as $key) {
$memcached_key = $this
->itemKey($key, $cache_bin);
$memcached_keys[$memcached_key] = $key;
}
// Perform preparations for the debug logging.
if (!empty($this->debug)) {
DrupalMemcachedDebug::prepare();
}
// Get all cache items from memcached.
$result = $this->memcached
->getMulti(array_keys($memcached_keys));
// Logs the debug entry about the memcached operation.
if (!empty($this->debug)) {
DrupalMemcachedDebug::process('get', $result, $memcached_keys, $cache_bin, $this->cluster);
}
// Replace formatted memcached keys by Drupal keys.
$cache = [];
foreach ($result as $memcached_key => $value) {
$normal_key = $memcached_keys[$memcached_key];
$cache[$normal_key] = $value;
}
return $cache;
}