public function DepcalcCacheBackend::invalidateTags in Dependency Calculation 8
Marks cache items with any of the specified tags as invalid.
Parameters
string[] $tags: The list of tags for which to invalidate cache items.
Overrides CacheTagsInvalidatorInterface::invalidateTags
File
- src/
Cache/ DepcalcCacheBackend.php, line 197
Class
- DepcalcCacheBackend
- Class DepcalcCacheBackend
Namespace
Drupal\depcalc\CacheCode
public function invalidateTags(array $tags) {
if (!Uuid::isValid(reset($tags))) {
// If the first item is not a UUID then none of them are.
return;
}
if ($this->backend instanceof DatabaseBackend) {
// On module install, this will get called, so let's check that the table
// exists before doing anything.
if (!$this->connection
->schema()
->tableExists($this->bin)) {
return;
}
foreach ($tags as $tag) {
$result = $this->connection
->select($this->bin, 'bin')
->fields('bin', [
'cid',
])
->condition('tags', "%{$this->connection->escapeLike($tag)}%", 'LIKE')
->execute();
$cids = $result
->fetchCol();
if (empty($cids)) {
continue;
}
// Allow for invalidated cache to be invalidated too.
$this
->invalidateMultiple($cids, TRUE);
}
}
elseif ($this->backend instanceof CacheTagsInvalidatorInterface) {
$this->backend
->invalidateTags($tags);
}
}