protected DatabaseCacheTagsChecksum::calculateChecksum(array $tags)
Calculates the current checksum for a given set of tags.
Parameters
array $tags: The array of tags to calculate the checksum for.
Return value
int The calculated checksum.
File
- core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php, line 105
Class
- DatabaseCacheTagsChecksum
- Cache tags invalidations checksum implementation that uses the database.
Namespace
Drupal\Core\Cache
Code
protected function calculateChecksum(array $tags) { $checksum = 0; $query_tags = array_diff($tags, array_keys($this->tagCache)); if ($query_tags) { $db_tags = array(); try { $db_tags = $this->connection->query('SELECT tag, invalidations FROM {cachetags} WHERE tag IN ( :tags[] )', array(':tags[]' => $query_tags)) ->fetchAllKeyed(); $this->tagCache += $db_tags; } catch (\Exception $e) { // If the table does not exist yet, create. if (!$this->ensureTableExists()) { $this->catchException($e); } } // Fill static cache with empty objects for tags not found in the database. $this->tagCache += array_fill_keys(array_diff($query_tags, array_keys($db_tags)), 0); } foreach ($tags as $tag) { $checksum += $this->tagCache[$tag]; } return $checksum; }
Please login to continue.