You are here

protected function DrupalAPCCache::prepareItem in APC - Alternative PHP Cache 7

Prepare a cached item.

Checks that items are either permanent or did not expire.

Parameters

$cache: An item loaded from cache_get() or cache_get_multiple().

Return value

The item with data unserialized as appropriate or FALSE if there is no valid item to load.

2 calls to DrupalAPCCache::prepareItem()
DrupalAPCCache::get in ./drupal_apc_cache.inc
Returns data from the persistent cache.
DrupalAPCCache::getMultiple in ./drupal_apc_cache.inc
Returns data from the persistent cache when given an array of cache IDs.

File

./drupal_apc_cache.inc, line 156
This integrates the drupal APC cache backend.

Class

DrupalAPCCache
APC cache implementation.

Code

protected function prepareItem($cache) {
  if (!isset($cache->data)) {
    return FALSE;
  }

  // If enforcing a minimum cache lifetime, validate that the data is
  // currently valid for this user before we return it by making sure the cache
  // entry was created before the timestamp in the current session's cache
  // timer. The cache variable is loaded into the $user object by _drupal_session_read()
  // in session.inc. If the data is permanent or we're not enforcing a minimum
  // cache lifetime always return the cached data.
  global $user;
  if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && (isset($user->cache) && $user->cache > $cache->created)) {

    // This cache data is too old and thus not valid for us, ignore it.
    return FALSE;
  }
  return $cache;
}