You are here

function apdqc_inflate_unserialize in Asynchronous Prefetch Database Query Cache 7

2 calls to apdqc_inflate_unserialize()
APDQCache::prepareItem in ./apdqc.cache.inc
Prepares a cached item.
apdqc_init in ./apdqc.module
Implements hook_init().

File

./apdqc.cache.inc, line 226
Extends Drupal's default database cache so async queries happen.

Code

function apdqc_inflate_unserialize(&$cache) {
  $converted = FALSE;
  if (is_array($cache)) {
    $cache = (object) $cache;
    $converted = TRUE;
  }

  // If the data is compressed, uncompress it.
  if ($cache->serialized > 1) {
    $inflate = @gzinflate($cache->data);
    if ($inflate !== FALSE && $cache->data !== FALSE) {
      $cache->data = $inflate;
    }
    $cache->serialized -= 2;
  }

  // If the data is permanent or not subject to a minimum cache lifetime,
  // unserialize and return the cached data.
  if ($cache->serialized) {
    $data = @unserialize($cache->data);
    if ($cache->data === 'b:0;' || $data !== FALSE) {
      $cache->data = $data;
    }
  }
  if ($converted) {
    $cache = (array) $cache;
  }
}