Re: Output_Cache Module
| From: | Vinai Kopp | Date: | Sat, 24 Feb 2001 15:32:01 +0000 |
| Subject: | Re: Output_Cache Module | ||
| References: | 1 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-1494@lists.php.net to get a copy of this message | ||
"Jesus M. Castagnetto" wrote:
> I think you might also want to add some locking
> mechanism when caching to a file, in this way 2
> different script instances will not get into a race
> condition.
Right.
>
> It might not belong in the design you are using, but
> checking for validity of the data will also be
> important, so the caching will happen automagically
> when the data changes. Assuming that the script is
> pulling data from a source that can be checked using a
> timestamp or an MD5 hash, etc.
I tend to go with Blörn Schotte's Idea of a is_valid_cache() Method that
can be overridden in an extended class, since validation is quite a bit
of overhead and at the moment our cached data is always out of date, but
I still cache it for some time to reduce the DB-Server.
>
> Caching different output depending on variables will
> be also useful. So, for example, you could cache info
> from a page that generates different ouput depending
> on the user type (admin, guest, etc.)
Shouldn't that be possible by appending an extra string or character to
the cache-id? But I'm not sure I got you here
>
> I wrote someting along these lines over a year ago (I
> mentioned this before), released the code on June last
> year, and have contended with some of the issues
> above. If you find the ideas useful, check the docs
> (and the .tar.gz files) at
> www.scripps.edu/~jesusmc/cachedtpl, or at
> www.castagnetto.org/CachedTemplate.php (last site
> -unfinished- uses that class)
Great Idea. Looks perfect for working with Template Classes. Your
approach is great because it works with all (well - at least a lot of)
Template classes. I was thinking along the lines of building a
Cache/Templates.php class, maybe it could make use of your work....
I believe there isn't *the* perfect Template Class, each have their
strengths and weaknesses and were built for different purposes.
Vinai