Re: quick cache question

From: Date: Tue, 13 Nov 2001 09:33:35 +0000
Subject: Re: quick cache question
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-506@lists.php.net to get a copy of this message
In <NFBBJMHFALJEBHCDMJPMOEKOCKAA.graeme@inetix.com.au>, Graeme Merrall wrote: > 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. try $cache->start($cache_id) instead of $cache->load($cache_id) ( or $cache->get() for not Output-related stuff (eg image and function)). $cache->get/start do the expiry check for you, but start() additionaly starts the ob_ stuff (and ->end ends it). see the example in Cache/Output.php chregu

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