You are here

public function DatabaseRawBackend::deleteMultiple in Supercache 8

Same name and namespace in other branches
  1. 2.0.x src/Cache/DatabaseRawBackend.php \Drupal\supercache\Cache\DatabaseRawBackend::deleteMultiple()

Deletes multiple items from the cache.

If the cache items are being deleted because they are no longer "fresh", you may consider using invalidateMultiple() instead. This allows callers to retrieve the invalid items by calling get() with $allow_invalid set to TRUE. In some cases an invalid item may be acceptable rather than having to rebuild the cache.

Parameters

array $cids: An array of cache IDs to delete.

Overrides CacheRawBackendInterface::deleteMultiple

See also

\Drupal\supercache\Cache\CacheRawBackendInterface::delete()

\Drupal\supercache\Cache\CacheRawBackendInterface::deleteAll()

1 call to DatabaseRawBackend::deleteMultiple()
DatabaseRawBackend::delete in src/Cache/DatabaseRawBackend.php
Deletes an item from the cache.

File

src/Cache/DatabaseRawBackend.php, line 282
Contains \Drupal\supercache\Cache\DatabaseRawBackend.

Class

DatabaseRawBackend
Defines a default cache implementation.

Namespace

Drupal\supercache\Cache

Code

public function deleteMultiple(array $cids) {
  $cids = array_values(array_map(array(
    $this,
    'normalizeCid',
  ), $cids));
  try {

    // Delete in chunks when a large array is passed.
    // TODO: Really this should be transactional....
    foreach (array_chunk($cids, 1000) as $cids_chunk) {
      $this->connection
        ->delete($this->bin)
        ->condition('cid', $cids_chunk, 'IN')
        ->execute();
    }
  } catch (\Exception $e) {

    // Create the cache table, which will be empty. This fixes cases during
    // core install where a cache table is cleared before it is set
    // with {cache_render} and {cache_data}.
    if (!$this
      ->ensureBinExists()) {
      $this
        ->catchException($e);
    }
  }
}