RE: [PEAR] quick cache question
| From: | Christian Stocker | Date: | Wed, 14 Nov 2001 11:42:22 +0000 |
| Subject: | RE: [PEAR] quick cache question | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-508@lists.php.net to get a copy of this message | ||
In <NFBBJMHFALJEBHCDMJPMAELJCKAA.graeme@inetix.com.au>, Graeme Merrall
wrote:
>> 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.
>>
>>
> Hmm this is wierd. Tried it this way and inserting a 'CACHE HIT' and
> 'CACHE MISS' in the relevant spots to see what happens. The first time
> out I get no output. When I refresh the page I get both sets of data -
> both 'CACHE MISS' and 'CACHE HIT' on the same page. Then when the cache
> expires and it has to re-render the page I get no output again. I wonder
> if my CVS copy of PHp is borked or if there is some odd IT[X]
> interaction going on. Any thoughts?
did you really wrote "echo $cache->end($expire)"? the echo is important.
then maybe you have CACHE MISS in the cached stuff, so it outputs also if
you have a cache hit.
just some thoughts.
chregu