You are here

public function RedisCacheTagsChecksum::doInvalidateTags in Redis 8

Marks cache items with any of the specified tags as invalid.

Parameters

string[] $tags: The set of tags for which to invalidate cache items.

Overrides CacheTagsChecksumTrait::doInvalidateTags

File

src/Cache/RedisCacheTagsChecksum.php, line 56

Class

RedisCacheTagsChecksum
Cache tags invalidations checksum implementation that uses redis.

Namespace

Drupal\redis\Cache

Code

public function doInvalidateTags(array $tags) {
  $keys = array_map([
    $this,
    'getTagKey',
  ], $tags);

  // We want to differentiate between PhpRedis and Redis clients.
  if ($this->clientType === 'PhpRedis') {
    $multi = $this->client
      ->multi();
    foreach ($keys as $key) {
      $multi
        ->incr($key);
    }
    $multi
      ->exec();
  }
  elseif ($this->clientType === 'Predis') {
    $pipe = $this->client
      ->pipeline();
    foreach ($keys as $key) {
      $pipe
        ->incr($key);
    }
    $pipe
      ->execute();
  }
}