protected function DrupalDatabaseCache::garbageCollection
protected DrupalDatabaseCache::garbageCollection()
Garbage collection for get() and getMultiple().
Parameters
$bin: The bin being requested.
File
- includes/cache.inc, line 373
- Functions and interfaces for cache handling.
Class
- DrupalDatabaseCache
- Defines a default cache implementation.
Code
protected function garbageCollection() { $cache_lifetime = variable_get('cache_lifetime', 0); // 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_expiration'])) { $expire = REQUEST_TIME - $cache_lifetime; foreach ($_SESSION['cache_expiration'] as $bin => $timestamp) { if ($timestamp < $expire) { unset($_SESSION['cache_expiration'][$bin]); } } if (!$_SESSION['cache_expiration']) { unset($_SESSION['cache_expiration']); } } // Garbage collection of temporary items is only necessary when enforcing // a minimum cache lifetime. if (!$cache_lifetime) { return; } // When cache lifetime is in force, avoid running garbage collection too // often since this will remove temporary cache items indiscriminately. $cache_flush = variable_get('cache_flush_' . $this->bin, 0); if ($cache_flush && ($cache_flush + $cache_lifetime <= REQUEST_TIME)) { // Reset the variable immediately to prevent a meltdown in heavy load situations. variable_set('cache_flush_' . $this->bin, 0); // Time to flush old cache data db_delete($this->bin) ->condition('expire', CACHE_PERMANENT, '<>') ->condition('expire', $cache_flush, '<=') ->execute(); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!cache.inc/function/DrupalDatabaseCache::garbageCollection/7.x