You are here

public function DrupalMemcached::deleteMulti in Memcache Storage 8

Bulk delete from the memcached pool.

Parameters

array $keys: List of cache keys to delete.

string $cache_bin: Name of the cache bin.

Overrides DrupalMemcachedInterface::deleteMulti

File

src/DrupalMemcached.php, line 188

Class

DrupalMemcached
Class DrupalMemcached

Namespace

Drupal\memcache_storage

Code

public function deleteMulti(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();
  }

  // Make a request to delete all cache items.
  $result = $this->memcached
    ->deleteMulti(array_keys($memcached_keys));

  // Logs the debug entry about the memcached operation.
  if (!empty($this->debug)) {
    DrupalMemcachedDebug::process('delete', $result, $memcached_keys, $cache_bin, $this->cluster);
  }
}