You are here

public function DepcalcCacheBackend::invalidateMultiple in Dependency Calculation 8

Marks cache items as invalid.

Invalid items may be returned in later calls to get(), if the $allow_invalid argument is TRUE.

Parameters

string[] $cids: An array of cache IDs to invalidate.

Overrides CacheBackendInterface::invalidateMultiple

See also

\Drupal\Core\Cache\CacheBackendInterface::deleteMultiple()

\Drupal\Core\Cache\CacheBackendInterface::invalidate()

\Drupal\Core\Cache\CacheBackendInterface::invalidateAll()

2 calls to DepcalcCacheBackend::invalidateMultiple()
DepcalcCacheBackend::invalidate in src/Cache/DepcalcCacheBackend.php
Marks a cache item as invalid.
DepcalcCacheBackend::invalidateTags in src/Cache/DepcalcCacheBackend.php
Marks cache items with any of the specified tags as invalid.

File

src/Cache/DepcalcCacheBackend.php, line 99

Class

DepcalcCacheBackend
Class DepcalcCacheBackend

Namespace

Drupal\depcalc\Cache

Code

public function invalidateMultiple(array $cids, $allow_invalid = FALSE) {
  $original_cids = $cids;

  // $this->getMultiple($cids) removes the successfully obtained $cids.
  // And because it is passed by reference then we need to invalidate
  // the original $cids.
  $cache_objects = $this
    ->getMultiple($cids, $allow_invalid);
  $this->backend
    ->invalidateMultiple($original_cids);
  if (!$cache_objects) {
    return;
  }

  /** @var \Drupal\depcalc\DependentEntityWrapperInterface[] $wrappers */
  $wrappers = array_map(function ($cache) {
    return $cache->data;
  }, $cache_objects);
  $event = new InvalidateDependenciesEvent($wrappers);
  $this->dispatcher
    ->dispatch(DependencyCalculatorEvents::INVALIDATE_DEPENDENCIES, $event);
}