You are here

function d8cache_OLD_invalidate_cache_tags in Drupal 8 Cache Backport 7

Backwards compatible version of d8cache_invalidate_cache_tags(). This will automatically be used when the core patch to implement end of transaction callbacks is missing.

Parameters

$tags:

1 call to d8cache_OLD_invalidate_cache_tags()
d8cache_invalidate_cache_tags in ./d8cache.module
Implements hook_invalidate_cache_tags().

File

./d8cache.module, line 72
Main module file for the D8 caching system backport.

Code

function d8cache_OLD_invalidate_cache_tags($tags) {
  $tag_cache =& drupal_static('d8cache_tag_cache', array());
  $invalidated_tags =& drupal_static('d8cache_invalidated_tags', array());
  foreach ($tags as $tag) {

    // Only invalidate tags once per request unless they are written again.
    if (isset($invalidated_tags[$tag])) {
      continue;
    }
    $invalidated_tags[$tag] = TRUE;
    unset($tag_cache[$tag]);
    db_merge('d8cache_cache_tags')
      ->key(array(
      'tag' => $tag,
    ))
      ->fields(array(
      'invalidations' => 1,
    ))
      ->expression('invalidations', 'invalidations + 1')
      ->execute();
    _d8cache_cache_tags_invalidate_cache($tag);
  }
}