chregu          Fri Mar 23 10:36:37 2001 EDT

  Modified files:              (Branch: PHP_4_0_5)
    /php4/pear/Cache    Output.php 
  Log:
  GarbageCollection was moved into a PEAR-Deconstructor
  (from the HEAD Branch)
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.11 php4/pear/Cache/Output.php:1.11.2.1
--- php4/pear/Cache/Output.php:1.11     Sat Mar 10 23:46:58 2001
+++ php4/pear/Cache/Output.php  Fri Mar 23 10:36:36 2001
@@ -17,64 +17,78 @@
 // |          Vinai Kopp <[EMAIL PROTECTED]>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: Output.php,v 1.11 2001/03/11 07:46:58 sbergmann Exp $
+// $Id: Output.php,v 1.11.2.1 2001/03/23 18:36:36 chregu Exp $
 
 require_once 'Cache.php';
 
 /**
 * Class to cache the output of a script using the output buffering functions
 *
-* Simple output cache. Some pages require lots of time to compute. Caching the 
+* Simple output cache. Some pages require lots of time to compute. Caching the
 * output can increase the overall speed dramatically, especially if you use
 * a Shared Memory storage container.
-* 
-* As you can see in the example the usage is extemely simple. To cache a script 
-* simple put some few lines of code in front of your script and some at the end. 
-* A preferrable place for this are the auto_prepend and auto_append files (=> 
php.ini). 
-* 
+*
+* As you can see in the example the usage is extemely simple. To cache a script
+* simple put some few lines of code in front of your script and some at the end.
+* A preferrable place for this are the auto_prepend and auto_append files (=> 
+php.ini).
+*
 * Usage example:
 *
 *  // place this somewhere in a central config file
 *  define(CACHE_STORAGE_CLASS, "file");
-* // file storage needs a dir to put the cache files
-* define(CACHE_DIR, "/var/tmp/");
+*  // file storage needs a dir to put the cache files
+*  define(CACHE_DIR, "/var/tmp/");
 *
-* // get a cache object
+*  // get a cache object
 *  $cache = new Cache_Output(CACHE_STORAGE_CLASS, array("cache_dir" => CACHE_DIR));
 *
 *  // compute the unique handle.
-*  // if your script depends on Cookie and HTTP Post data as well 
+*  // if your script depends on Cookie and HTTP Post data as well
 *  // you should use:
-*  // $cache_handle = array( 
+*  // $cache_handle = array(
 *  //                       "file" => $REQUEST_URI,
 *  //                       "post" => $HTTP_POST_VAS"
 *  //                       "cookie"  => $HTTP_COOKIE_VARS
 *  //                    );
-*  $cache_handle = $REQUEST_URI;
-* 
-*  // now the magic happens: if cached call die() 
+*  // But be warned, using all GET or POST Variables as a seed
+*  // can be used for a DOS attack. Calling 
+http://www.example.com/example.php?whatever
+*  // where whatever is a random text might be used to flood your cache.
+*  $cache_handle = $cache->generateID($REQUEST_URI);
+*
+*  // now the magic happens: if cached call die()
 *  // to end the time consumptiong script script execution and use the cached value!
 *  if ($content = $cache->start($cache_handle)) {
 *     print $content;
+*     print "<p>Cache hit</p>";
 *     die();
 *  }
-*  
-*  // time consumption script goes here. 
-* 
+*
+*  // time consumption script goes here.
+*
 *  // store the output of the cache into the cache and print the output.
 *  print $cache->end();
-* 
-* If you do not want to cache a whole page - no problem:
-* 
-* if (!($content = $cache->start($cache_handle))) {
-*    // do the computation here
-*    print $cache->end()
-* } else {
-    print $content;
-* }
+*  print "<p>Cache miss, stored using the ID '$id'.</p>";
+*
+*  If you do not want to cache a whole page - no problem:
+*
+*  if (!($content = $cache->start($cache_handle))) {
+*     // do the computation here
+*     print $cache->end()
+*  } else {
+     print $content;
+*  }
+*
+*  If you need an example script check the (auto_)prepend and (auto_)append
+*  files of my homepage:
+*
+*    http://www.ulf-wendel.de/php/show_source.php?file=prepend
+*    http://www.ulf-wendel.de/php/show_source.php?file=append
 *
-* Have fun!
-* 
+*  Don't know how to use it or you need profiling informations?`
+*  Ask Christian he was patient with me and he'll be so with your questions ;).
+*
+*  Have fun!
+*
 * @authors  Ulf Wendel <[EMAIL PROTECTED]>
 * @version  $ID: $
 * @package  Cache
@@ -84,7 +98,7 @@
 
     /**
     * ID passed to start()
-    * 
+    *
     * @var  string
     * @see  start(), end()
     */
@@ -92,25 +106,34 @@
 
     /**
     * Group passed to start()
-    * 
-    * @var  string  
+    *
+    * @var  string
     * @see  start(), end()
     */
     var $output_group = "";
 
     /**
+    * PEAR-Deconstructor
+    * Call deconstructor of parent
+    */
+    function _Cache_Output()
+    {
+                $this->_Cache();
+    }
+
+    /**
     * starts the output buffering and returns an empty string or returns the cached 
output from the cache.
-    * 
+    *
     * @param    string  dataset ID
     * @param    string  cache group
-    * @return   string  
+    * @return   string
     * @access   public
     */
     function start($id, $group = "default") {
         if ($this->no_cache)
             return "";
 
-        // this is already cached return it from the cache so that the user 
+        // this is already cached return it from the cache so that the user
         // can use the cache content and stop script execution
         if ($content = $this->get($id, $group))
             return $content;
@@ -152,14 +175,14 @@
     * @brother  end()
     */
     function endPrint($expire = 0, $userdata = "") {
-        print $this->end($expire, $userdata);      
+        print $this->end($expire, $userdata);
     } // end func endPrint
 
     /**
     * Returns the content of the output buffer but does not store it into the cache.
     *
-    * Use this method if the content of your script is markup (XML) 
-    * that has to be parsed/converted (XSLT) before you can output 
+    * Use this method if the content of your script is markup (XML)
+    * that has to be parsed/converted (XSLT) before you can output
     * and store it into the cache using save().
     *
     * @return   string



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to