You are here

function _d8cache_cache_tags_load_from_db in Drupal 8 Cache Backport 7

Loads cache tag invalidations from the database.

Parameters

array $query_tags: The tags to query from the database.

Return value

array An array keyed by tag with invalidations as value. Using 0 if no invalidation occured, yet.

1 call to _d8cache_cache_tags_load_from_db()
_d8cache_cache_tags_calculate_checksum in ./d8cache.module
Calculates the current checksum for a given set of tags.

File

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

Code

function _d8cache_cache_tags_load_from_db($query_tags) {
  $result = array();

  // Ensure database is loaded, since we can get called to load missing tags
  // during DRUPAL_BOOTSTRAP_PAGE_CACHE. This is a recursive call.
  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE, FALSE);
  if ($db_tags = db_query('SELECT tag, invalidations FROM {d8cache_cache_tags} WHERE tag IN (:tags)', array(
    ':tags' => $query_tags,
  ))
    ->fetchAllKeyed()) {
    $result += $db_tags;
  }

  // Fill static cache with empty objects for tags not found in the database.
  $result += array_fill_keys(array_diff($query_tags, array_keys($db_tags)), 0);
  return $result;
}