Re: quick cache question
| From: | Nicolas Hoizey | Date: | Tue, 13 Nov 2001 09:24:30 +0000 |
| Subject: | Re: quick cache question | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-505@lists.php.net to get a copy of this message | ||
Hi,
GM> Is there a right way to manage caching and expired files that I've missed?
I'm not sure it's the "right" way, but I use it like the following :
<?php
require_once 'Cache/Output.php';
$cache = new Cache_Output('file', array('cache_dir' =>
'/var/www/cache/'));
$cacheHandle = $cache->generateID('id_key');
if (!($content = $cache->start($cacheHandle))) {
// my stuff begins here
...
// my stuff ends here
echo $cache->end(60*60*24);
} else {
echo $content;
}
Of course, replace 'id_key' by whatever you want, and "60*60*24" by
your own cache timeout.
HTH
-Nicolas
--
Nicolas Hoizey
Free PHP projects http://www.phpheaven.net
Veille tous azimuts http://www.gasteroprod.com