-- stevep98 <[EMAIL PROTECTED]> wrote
(on Friday, 07 November 2008, 02:49 PM -0800):
> Here are my main questions:
> 
> a) Is there any way to store a variable (I'm thinking things like
> database handles, config objects) such that it can be retrieved in the
> same apache process when it is processing the next request (not using
> session, since that's specific to a user).

Yes and no. memcached, APC, and Zend Platform all offer caching
abilities, as does, in a more limited fashion, PHP's shm support.
However, you're limited in what you can cache. It's typically not a
great idea to cache actual objects, and you *can't* cache DB handles and
other resources. Application and/or configuration data are good targets
for caching.

> b) Is there a way to store a variable such that it is visible in all
> apache processes through shared memory.

Yes -- see the above answer.

> I am aware that its possible to serialize things out manually and
> perhaps use the Cache system, but I am looking for a more direct
> method of sharing variables.
> 
> (There doesn't seem to be support for these features in Zend Platform
> either, right?)

Caching is the way to go here. Zend_Cache has a variety of backends,
targetting each of the systems I mentioned above, and this is a tried
and true methodology for scaling your applications. While you may think
of the Zend_Cache object as overhead, if your caching strategy is good,
it's much less overhead than the alternative.

Caching is a fine art -- you have to examine what your expensive
operations are, whether they can be cached, and if so, for how long.
This sort of thing requires a good knowledge of your systems, your
application, and the amount of traffic you receive.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to