From: Ulf Wendel Date: Thu, 19 Apr 2001 11:04:01 +0000 (+0000) Subject: - fixed the garbage collection X-Git-Tag: php-4.0.6RC1~369 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=457c638bfb0d0234da39a04f74921486900a187f;p=php - fixed the garbage collection Added some kind of LRU to delete all entries older than n seconds. This fixes the bug that cache entries with lifetime 0 (endless) never got removed although if they are no longer used. What's still missing is some space limit for cache data. --- diff --git a/pear/Cache.php b/pear/Cache.php index c2d0d450ca..8a8278c53c 100644 --- a/pear/Cache.php +++ b/pear/Cache.php @@ -82,7 +82,7 @@ class Cache extends PEAR { * of seconds. * * @var integer - * @see $gc_probability + * @see $gc_probability, $gc_maxlifetime * @access public */ var $gc_time = 1; @@ -93,10 +93,20 @@ class Cache extends PEAR { * TODO: Add an explanation. * * @var integer 0 => never - * @see $gc_time + * @see $gc_time, $gc_maxlifetime * @access public */ var $gc_probability = 1; + + /** + * Garbage collection: delete all entries not use for n seconds. + * + * Default is one day, 60 * 60 * 24 = 86400 seconds. + * + * @var integer + * @see $gc_probability, $gc_time + */ + var $gc_maxlifetime = 86400; /** * Storage container object. @@ -314,7 +324,7 @@ class Cache extends PEAR { // time and probability based if (($force) || ($last_run && $last_run < time() + $this->gc_time) || (rand(1, 100) < $this->gc_probability)) { - $this->container->garbageCollection(); + $this->container->garbageCollection($this->gc_maxlifetime); $last_run = time(); } } // end func garbageCollection