]> granicus.if.org Git - php/commitdiff
- fixed the garbage collection
authorUlf Wendel <uw@php.net>
Thu, 19 Apr 2001 11:04:01 +0000 (11:04 +0000)
committerUlf Wendel <uw@php.net>
Thu, 19 Apr 2001 11:04:01 +0000 (11:04 +0000)
  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.

pear/Cache.php

index c2d0d450ca72b3a9c0174e7e044094ed6c9433fd..8a8278c53c5f21d610183634c8b15882046de70e 100644 (file)
@@ -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