public function DrupalMemcache::setMulti in Memcache Storage 8
Bulk set if cache items to the memcached pool.
Parameters
array $items: List of cache items.
string $cache_bin: Name of the cache bin.
Overrides DrupalMemcachedInterface::setMulti
File
- src/
DrupalMemcache.php, line 93
Class
- DrupalMemcache
- Class DrupalMemcache
Namespace
Drupal\memcache_storageCode
public function setMulti(array $items, $cache_bin = '') {
// No point in performing any action is we're not connected to memcached.
if (empty($this->isConnected)) {
return;
}
// PECL memcache doesn't support multiple set, so just loop through
// every cache item and set it.
foreach ($items as $item) {
// Get formatted cache key.
$memcached_key = $this
->itemKey($item->cid, $cache_bin);
// Prepare the expiration time for memcached.
$expiration = $item->expire;
if ($item->expire == CacheBackendInterface::CACHE_PERMANENT) {
$expiration = 0;
}
// Perform preparations for the debug logging.
if (!empty($this->debug)) {
DrupalMemcachedDebug::prepare();
}
// Set the value to the memcached pool.
$compression = !empty($this->compressionEnabled) ? MEMCACHE_COMPRESSED : 0;
$result = $this->memcached
->set($memcached_key, $item, $compression, $expiration);
// Logs the debug entry about the memcached operation.
if (!empty($this->debug)) {
$memcached_keys = [
$memcached_key => $item->cid,
];
DrupalMemcachedDebug::process('set', $result, $memcached_keys, $cache_bin, $this->cluster);
}
}
}