function ApcuBackend::prepareItem
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/ApcuBackend.php \Drupal\Core\Cache\ApcuBackend::prepareItem()
- 8.9.x core/lib/Drupal/Core/Cache/ApcuBackend.php \Drupal\Core\Cache\ApcuBackend::prepareItem()
- 11.x core/lib/Drupal/Core/Cache/ApcuBackend.php \Drupal\Core\Cache\ApcuBackend::prepareItem()
Prepares a cached item.
Checks that the item is either permanent or did not expire.
Parameters
object $cache: An item loaded from self::get() or self::getMultiple().
bool $allow_invalid: If TRUE, a cache item may be returned even if it is expired or has been invalidated. See ::get().
Return value
mixed The cache item or FALSE if the item expired.
2 calls to ApcuBackend::prepareItem()
- ApcuBackend::get in core/
lib/ Drupal/ Core/ Cache/ ApcuBackend.php - Returns data from the persistent cache.
- ApcuBackend::getMultiple in core/
lib/ Drupal/ Core/ Cache/ ApcuBackend.php - Returns data from the persistent cache when given an array of cache IDs.
File
-
core/
lib/ Drupal/ Core/ Cache/ ApcuBackend.php, line 152
Class
- ApcuBackend
- Stores cache items in the Alternative PHP Cache User Cache (APCu).
Namespace
Drupal\Core\CacheCode
protected function prepareItem($cache, $allow_invalid) {
if (!isset($cache->data)) {
return FALSE;
}
$cache->tags = $cache->tags ? explode(' ', $cache->tags) : [];
// Check expire time.
$cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= $this->time
->getRequestTime();
// Check if invalidateTags() has been called with any of the entry's tags.
if (!$this->checksumProvider
->isValid($cache->checksum, $cache->tags)) {
$cache->valid = FALSE;
}
if (!$allow_invalid && !$cache->valid) {
return FALSE;
}
return $cache;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.