Re: Function caching...
| From: | Kristian Koehntopp | Date: | Fri, 08 Dec 2000 22:40:23 +0000 |
| Subject: | Re: Function caching... | ||
| References: | 1 2 3 4 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-40617@lists.php.net to get a copy of this message | ||
Ulf Wendel wrote:
> > I know sites who use wget to get a static version to serve the internet.
> > The php site is only used for easy editing
>
> With cached functions calls you could define a cache lifetime which
> allows you to automatically generate a "new version" every n seconds
> without the need of an external tool.
Actually, it is even more comfortable, as the cache is keyed by
the function name and parameters (using in our prototypes a md5
hash of the function name and the serialized parameters as a
key). That is, as soon as you call your function with new
parameters, it will generate a new hash key and new output.
You need to manually flush the cache as soon as you change any
aspect of the function that is not covered by the hash key, such
as values in a database that are not reflected by a change in
the parameters (i.e. you UPDATE values instead of INSERTing them
and call the function with the new id). You also need to flush
the cache as soon as you change the code of the function in a
way that affects the function result or output.
You do not really need lifetimes in the cache, as your functions
have to be side-effect free and idempotent to be cacheable. You
could use lifetimes as a safeguard (automatisch cache flush)
against bad code or practice, but they are not critical.
Kristian
--
Kristian Köhntopp, NetUSE AG Siemenswall, D-24107 Kiel
Tel: +49 431 386 436 00, Fax: +49 431 386 435 99
Using PHP3? See our web development library at http://phplib.netuse.de/