You are here

protected function Redis_Cache::expandEntry in Redis 7.3

Expand cache entry from fetched data

Parameters

array $values: Raw values fetched from Redis server data

Return value

array Or FALSE if entry is invalid

3 calls to Redis_Cache::expandEntry()
Redis_Cache::get in lib/Redis/Cache.php
Returns data from the persistent cache.
Redis_Cache::getMultiple in lib/Redis/Cache.php
Returns data from the persistent cache when given an array of cache IDs.
Redis_CacheCompressed::expandEntry in lib/Redis/CacheCompressed.php
Expand cache entry from fetched data
1 method overrides Redis_Cache::expandEntry()
Redis_CacheCompressed::expandEntry in lib/Redis/CacheCompressed.php
Expand cache entry from fetched data

File

lib/Redis/Cache.php, line 354

Class

Redis_Cache
Because those objects will be spawned during boostrap all its configuration must be set in the settings.php file.

Code

protected function expandEntry(array $values, $flushPerm, $flushVolatile) {

  // Check for entry being valid.
  if (empty($values['cid'])) {
    return;
  }

  // This ensures backward compatibility with older version of
  // this module's data still stored in Redis.
  if (isset($values['expire'])) {
    $expire = (int) $values['expire'];

    // Ensure the entry is valid and have not expired.
    if ($expire !== CACHE_PERMANENT && $expire !== CACHE_TEMPORARY && $expire <= time()) {
      return false;
    }
  }

  // Ensure the entry does not predate the last flush time.
  if ($this->allowTemporaryFlush && !empty($values['volatile'])) {
    $validityThreshold = max(array(
      $flushPerm,
      $flushVolatile,
    ));
  }
  else {
    $validityThreshold = $flushPerm;
  }
  if ($values['created'] <= $validityThreshold) {
    return false;
  }
  $entry = (object) $values;

  // Reduce the checksum to the real timestamp part
  $entry->created = (int) $entry->created;
  if ($entry->serialized) {
    $entry->data = unserialize($entry->data);
  }
  return $entry;
}