cvs: php4 /pear/Cache Output.php

From: Date: Fri, 16 Mar 2001 08:40:40 +0000
Subject: cvs: php4 /pear/Cache Output.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4604@lists.php.net to get a copy of this message
uw Fri Mar 16 00:40:40 2001 EDT Modified files: /php4/pear/Cache Output.php Log: Usage example changes should answer peoples FAQs. Index: php4/pear/Cache/Output.php diff -u php4/pear/Cache/Output.php:1.12 php4/pear/Cache/Output.php:1.13 --- php4/pear/Cache/Output.php:1.12 Thu Mar 15 23:58:35 2001 +++ php4/pear/Cache/Output.php Fri Mar 16 00:40:39 2001 @@ -17,7 +17,7 @@ // | Vinai Kopp <kopp@netzarbeiter.de> | // +----------------------------------------------------------------------+ // -// $Id: Output.php,v 1.12 2001/03/16 07:58:35 sbergmann Exp $ +// $Id: Output.php,v 1.13 2001/03/16 08:40:39 uw Exp $ require_once 'Cache.php'; @@ -36,10 +36,10 @@ * * // 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. @@ -50,12 +50,20 @@ * // "post" => $HTTP_POST_VAS" * // "cookie" => $HTTP_COOKIE_VARS * // ); +<<<<<<< Output.php +* // 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); +======= +* $cache_handle = $cache->generateID($REQUEST_URI); +>>>>>>> 1.12 * * // 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(); * } * @@ -63,17 +71,27 @@ * * // store the output of the cache into the cache and print the output. * print $cache->end(); +* print "<p>Cache miss, stored using the ID '$id'.</p>"; +* +* If you do not want to cache a whole page - no problem: * -* 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 (!($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 +* +* 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! +* Have fun! * * @authors Ulf Wendel <ulf.wendel@phpdoc.de> * @version $ID: $

« previous php.cvs (#4604) next »