|
Posted by ELINTPimp on 07/26/07 10:47
On Jul 25, 6:26 pm, Vladimir Ghetau <vladi...@pixeltomorrow.com>
wrote:
> Hi guys,
>
> I'm trying to get the best out of an application, powered by MySQL by
> simply grabbing everything into a big array, the use it along the code
> so I can avoid having too many requests to the database, which
> obviously slows down the script.
>
> I've played with xcache before, but because it wasn't my code I
> couldn't really understand the process completely.
>
> What is the best practice when you want to use array caching, and how
> to take advantage of it? There are many documents on how to speed your
> PHP applications, but I believe since php 5 became popular I can do
> better than simple tweaks.
>
> Thanks,
>
> Vladimir
PHP doesn't have persistance at the application level. There are a
few things that you're embarking on that doesn't smell right to me.
First, you'll have to pass those values from request to request, more
code (introducing bugs and maintenance nightmares) and overhead on the
webserver. Second, you're polluting your namespace with variables you
probably won't need in that request, introducing bugs and maintenance
nightmares. Have you tried using mysql as your storage persistance to
see how slow it really is? Typically, it isn't much at all, and it
makes life so much easier. For some variables, you can use, and
should, use $_SESSIONS...but there's no need to overdo it.
If you're REALLY sure that application scope persistance is what you
want, however, try looking up the REGISTRY design pattern. Good to
know, but it comes with it's own problems.
[Back to original message]
|