You are here

public function TimestampCacheTagsChecksum::getCurrentChecksum in Memcache API and Integration 8.2

Returns the sum total of validations for a given set of tags.

Called by a backend when storing a cache item.

Parameters

string[] $tags: Array of cache tags.

Return value

string Cache tag invalidations checksum.

Overrides CacheTagsChecksumInterface::getCurrentChecksum

File

src/Cache/TimestampCacheTagsChecksum.php, line 65

Class

TimestampCacheTagsChecksum
Cache tags invalidations checksum implementation by timestamp invalidation.

Namespace

Drupal\memcache\Cache

Code

public function getCurrentChecksum(array $tags) {

  // @todo Revisit the invalidatedTags hack.
  // Remove tags that were already invalidated during this request from the
  // static caches so that another invalidation can occur later in the same
  // request. Without that, written cache items would not be invalidated
  // correctly.
  foreach ($tags as $tag) {
    unset($this->invalidatedTags[$tag]);
  }

  // Taking the minimum of the current timestamp and the checksum is used to
  // ensure that items that are not valid yet are identified properly as not
  // valid. The checksum will change continuously until the item is valid,
  // at which point the checksum will match and freeze at that value.
  return min($this->invalidator
    ->getCurrentTimestamp(), $this
    ->calculateChecksum($tags));
}