protected function CacheBase::expandEntry in Redis 8
Prepares a cached item.
Checks that items are either permanent or did not expire, and unserializes data as appropriate.
Parameters
array $values: The hash returned from redis or false.
bool $allow_invalid: If FALSE, the method returns FALSE if the cache item is not valid.
Return value
mixed|false The item with data unserialized as appropriate and a property indicating whether the item is valid, or FALSE if there is no valid item to load.
2 calls to CacheBase::expandEntry()
- PhpRedis::getMultiple in src/
Cache/ PhpRedis.php - Returns data from the persistent cache when given an array of cache IDs.
- Predis::getMultiple in src/
Cache/ Predis.php - Returns data from the persistent cache when given an array of cache IDs.
File
- src/
Cache/ CacheBase.php, line 298
Class
- CacheBase
- Base class for redis cache backends.
Namespace
Drupal\redis\CacheCode
protected function expandEntry(array $values, $allow_invalid) {
// Check for entry being valid.
if (empty($values['cid'])) {
return FALSE;
}
// Ignore items that are scheduled for deletion.
if (in_array($values['cid'], $this->delayedDeletions)) {
return FALSE;
}
$cache = (object) $values;
$cache->tags = explode(' ', $cache->tags);
// Check expire time, allow to have a cache invalidated explicitly, don't
// check if already invalid.
if ($cache->valid) {
$cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME;
// Check if invalidateTags() has been called with any of the items's tags.
if ($cache->valid && !$this->checksumProvider
->isValid($cache->checksum, $cache->tags)) {
$cache->valid = FALSE;
}
}
// Ensure the entry does not predate the last delete all time.
$last_delete_timestamp = $this
->getLastDeleteAll();
if ($last_delete_timestamp && (double) $values['created'] < $last_delete_timestamp) {
return FALSE;
}
if (!$allow_invalid && !$cache->valid) {
return FALSE;
}
if (!empty($cache->gz)) {
// Uncompress, suppress warnings e.g. for broken CRC32.
$cache->data = @gzuncompress($cache->data);
// In such cases, void the cache entry.
if ($cache->data === FALSE) {
return FALSE;
}
}
if ($cache->serialized) {
$cache->data = $this->serializer
->decode($cache->data);
}
return $cache;
}