protected function MemoryBackend::prepareItem in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Cache/MemoryBackend.php \Drupal\Core\Cache\MemoryBackend::prepareItem()
Prepares a cached item.
Checks that items are either permanent or did not expire, and returns data as appropriate.
Parameters
object $cache: An item loaded from cache_get() or cache_get_multiple().
bool $allow_invalid: (optional) If TRUE, cache items may be returned even if they have expired or been invalidated.
Return value
mixed The item with data as appropriate or FALSE if there is no valid item to load.
2 calls to MemoryBackend::prepareItem()
- MemoryBackend::get in core/
lib/ Drupal/ Core/ Cache/ MemoryBackend.php - Returns data from the persistent cache.
- MemoryBackend::getMultiple in core/
lib/ Drupal/ Core/ Cache/ MemoryBackend.php - Returns data from the persistent cache when given an array of cache IDs.
File
- core/
lib/ Drupal/ Core/ Cache/ MemoryBackend.php, line 84 - Contains \Drupal\Core\Cache\MemoryBackend.
Class
- MemoryBackend
- Defines a memory cache implementation.
Namespace
Drupal\Core\CacheCode
protected function prepareItem($cache, $allow_invalid) {
if (!isset($cache->data)) {
return FALSE;
}
// The object passed into this function is the one stored in $this->cache.
// We must clone it as part of the preparation step so that the actual
// cache object is not affected by the unserialize() call or other
// manipulations of the returned object.
$prepared = clone $cache;
$prepared->data = unserialize($prepared->data);
// Check expire time.
$prepared->valid = $prepared->expire == Cache::PERMANENT || $prepared->expire >= $this
->getRequestTime();
if (!$allow_invalid && !$prepared->valid) {
return FALSE;
}
return $prepared;
}