You are here

public function CacheTagsChecksumMongodb::invalidateTags in MongoDB 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/CacheTagsChecksumMongodb.php, line 51
Contains \Drupal\mongodb\CacheTagsChecksumMongodb.

Class

CacheTagsChecksumMongodb

Namespace

Drupal\mongodb

Code

public function invalidateTags(array $tags) {
  foreach ($tags as $tag) {

    // Only invalidate tags once per request unless they are written again.
    if (isset($this->invalidatedTags[$tag])) {
      continue;
    }
    $this->invalidatedTags[$tag] = TRUE;
    unset($this->tagCache[$tag]);
    $this->mongo
      ->get('cachetags')
      ->update([
      'tag' => $tag,
    ], [
      '$inc' => [
        'invalidations' => 1,
      ],
    ], [
      'upsert' => TRUE,
    ]);
  }
}