You are here

protected function MemCacheDrupal::garbageCollection in Memcache API and Integration 7

Garbage collection for get() and getMultiple().

This functions check for session indicators to NOT use the cache. It checks if the last cache clearing time in there expired and if so unsets them, so anonymous users can get out of the "sessions" after some time, to get fast delivered pages (e.g. from Varnish etc. again).

2 calls to MemCacheDrupal::garbageCollection()
MemCacheDrupal::get in ./memcache.inc
Implements DrupalCacheInterface::get().
MemCacheDrupal::getMultiple in ./memcache.inc
Implements DrupalCacheInterface::getMultiple().

File

./memcache.inc, line 96

Class

MemCacheDrupal
Implementation of cache.inc with memcache logic included

Code

protected function garbageCollection() {

  // Clean-up the per-user cache expiration session data, so that the session
  // handler can properly clean-up the session data for anonymous users.
  if (isset($_SESSION['cache_flush'])) {
    foreach ($_SESSION['cache_flush'] as $bin => $timestamp) {
      $expire = REQUEST_TIME - variable_get('cache_lifetime_' . $this->bin, variable_get('cache_lifetime', 0));
      if ($timestamp < $expire) {
        unset($_SESSION['cache_flush'][$bin]);
      }
    }
    if (!$_SESSION['cache_flush']) {
      unset($_SESSION['cache_flush']);
    }
  }
}