Re: [PHP-PEAR] Output_Cache Module

[email protected] (Björn Schotte)
Newsgroups php.pear
Message-ID <[email protected]>
Hi,

> As i wrote yesterday, I wrote two caching classes. one which caches the
> entire output (the html-file, the visitor normally gets)

I have to note that there will be many situations where the
developer only wants to cache _some_ data. On our shopping
sites we have a complex navigation tree. We assume that the
tree won't change as often as the >1 Mio. product datas
will. So we cache the HTML box which displays the navigation
tree (for X hours). In other situations, other "HTML boxes"
( = kind of data, not the whole HTML output) will be cached.

So I don't think it will be a good idea to cache all the
output. If the user wants, he can cache the output, so
I suggest a core which caches generic data and put on the
API another function which uses ob_* to retrieve all output
and calls the API to cache this output.

This will be flexible: User A wants to cache all output,
so he initializes the class with "I want to cache anything".
User B only wants to cache some data, so he initializes
the class "I want to cache pieces" and calls specific
API functions to store and retrieve his data containers.

> > - store data in a data container (shared
> >   memory, DB, ...)
> i have db and filesystem, no idea about shared memory.

shared memory is very ugly to handle. I don't have any
experience with shmop_* at the moment (mental note: give
a tutorial on shmop_* in one of my next newsletters) but
only with shm_* which seem to be very ugly.

I recently had a discussion with Kristian Koehntopp
where I told him the system with my banner cache and
which problems I had to solve. He suggested that PHP
should solve itself the problem with shared handling
of variables, so that you define:

  shared $foo = "bar";

and PHP itself knows "Okay, $foo is now shared, I lookup
on php.ini [or any other config resource or runtime config
variable] where the sysadmin wants to have variables shared.
Ah, okay, he wants to have it in shared memory [database,
filesystem, ...], so I handle things with ugly shared memory".
In any other PHP script, you now have the variable $foo automatically
with its content "foo". This model expects that you have something
like an "application server" or a never-ending process which
controls the resources and where every PHP child script asks
the big never ending process "Hey, which variables are shared,
give me their names and their content, so that I can put them
into my GLOBALS[] hash".

This is a future-point and perhaps will be solved soon
with one of the alternatives that are coming up.

-- 
Björn Schotte                               [email protected]
http://rent-a-phpwizard.de/                   [email protected]

Software dev advocate: http://www.advogato.org/person/baerli/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.