You are here

protected function MemcacheBackend::valid in Memcache API and Integration 8.2

Determines if the cache item is valid.

This also alters the valid property of the cache item itself.

Parameters

string $cid: The cache ID.

\stdClass $cache: The cache item.

Return value

bool TRUE if valid, FALSE otherwise.

1 call to MemcacheBackend::valid()
MemcacheBackend::getMultiple in src/MemcacheBackend.php
Returns data from the persistent cache when given an array of cache IDs.

File

src/MemcacheBackend.php, line 179

Class

MemcacheBackend
Defines a Memcache cache backend.

Namespace

Drupal\memcache

Code

protected function valid($cid, \stdClass $cache) {
  $cache->valid = TRUE;

  // Items that have expired are invalid.
  if ($cache->expire != CacheBackendInterface::CACHE_PERMANENT && $cache->expire <= REQUEST_TIME) {
    $cache->valid = FALSE;
  }

  // Check if invalidateTags() has been called with any of the items's tags.
  if (!$this->checksumProvider
    ->isValid($cache->checksum, $cache->tags)) {
    $cache->valid = FALSE;
  }
  return $cache->valid;
}