protected function MemoryBackend::prepareItem

Prepares a cached item.

Checks that items are either permanent or did not expire, and returns data as appropriate.

Parameters

stdClass $cache: An item loaded from cache_get() or cache_get_multiple().

Return value

mixed The item with data as appropriate or FALSE if there is no valid item to load.

2 calls to MemoryBackend::prepareItem()

File

drupal/core/lib/Drupal/Core/Cache/MemoryBackend.php, line 80
Definition of Drupal\Core\Cache\ArrayBackend.

Class

MemoryBackend
Defines a memory cache implementation.

Namespace

Drupal\Core\Cache

Code

protected function prepareItem($cache, $allow_invalid) {
  if (!isset($cache->data)) {
    return FALSE;
  }

  // Check expire time.
  $cache->valid = $cache->expire == CacheBackendInterface::CACHE_PERMANENT || $cache->expire >= REQUEST_TIME;
  if (!$allow_invalid && !$cache->valid) {
    return FALSE;
  }
  return $cache;
}