quick cache question

From: Date: Tue, 13 Nov 2001 05:31:00 +0000
Subject: quick cache question
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-504@lists.php.net to get a copy of this message
Just having a play with the PEAR cache class to cache page output from IT[X]. Seems to work quite well so far. One question regarding managing expiry though. From some reading of done we generate a cache id to identify the file in question with apologies for wrapping/laout $cache = new Cache('file', array('cache_dir'=>'cache/')); $cache_id = $cache->generateID(array( 'url'=>$REQUEST_URI, 'get'=>$HTTP_GET_VARS ) ); if ($content = $cache->load($cache_id)) { echo "Cache Hit"; echo $content; die(); } $page = "some content"; $expiry = 10; //seconds $cache->save($cache_id, $page, $expiry); which caches fine but seems to ignore the expiry time. Cache/Container.php comments indicate that this is a better method and it seems to work if ($cache->isCached($cache_id) && !$cache->isExpired($cache_id)) { $content = $cache->load($cache_id); echo "Cache Hit"; echo $content; die(); } However, Cache_Container::isCached() is documented as a private function. From looking at the way the script is supposed to work although it would seem that the method used above is not optimal. Is there a right way to manage caching and expired files that I've missed? Can't wait to tinker with the image and function caching stuff... Cheers, Graeme

« previous php.pear.general (#504) next »