protected function MemoryCache::prepareItem in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php \Drupal\Core\Cache\MemoryCache\MemoryCache::prepareItem()
- 9 core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php \Drupal\Core\Cache\MemoryCache\MemoryCache::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 self::get() or self::getMultiple().
bool $allow_invalid: (optional) If TRUE, cache items may be returned even if they have expired or been invalidated. Defaults to FALSE.
Return value
mixed The item with data as appropriate or FALSE if there is no valid item to load.
Overrides MemoryBackend::prepareItem
File
- core/
lib/ Drupal/ Core/ Cache/ MemoryCache/ MemoryCache.php, line 33
Class
- MemoryCache
- Defines a memory cache implementation.
Namespace
Drupal\Core\Cache\MemoryCacheCode
protected function prepareItem($cache, $allow_invalid = FALSE) {
if (!isset($cache->data)) {
return FALSE;
}
// Check expire time.
$cache->valid = $cache->expire == static::CACHE_PERMANENT || $cache->expire >= $this
->getRequestTime();
if (!$allow_invalid && !$cache->valid) {
return FALSE;
}
return $cache;
}