You are here

public function DrupalMemcache::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/DrupalMemcache.php, line 174

Class

DrupalMemcache
Class DrupalMemcache

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;
  }

  // PECL memcache doesn't support multiple deletion of elements, so
  // loop through all elements and delete one by one.
  foreach ($keys as $key) {
    $memcached_key = $this
      ->itemKey($key, $cache_bin);

    // Perform preparations for the debug logging.
    if (!empty($this->debug)) {
      DrupalMemcachedDebug::prepare();
    }
    $result = $this->memcached
      ->delete($memcached_key);

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