Is it possible to pool data or functionality in PHP?
The amateur-ish PHP code that I write wakes up to handle a response, loads functions, opens database connections, create objects, initialises them, and then - dies after 0.01 secs when the response has been processed, leaving the next request to reload, parse, and run mainly the same thing again.
That's non-sensical, and I find it removes the value of a lot of my work not to have functionality/data/object pooling. For example I can write classes, to find they all get reinitialised with each request - what's the point of me trying to develop a meaningful object structure?
And so: how can I write PHP to pool data and functionality?
There is no 1 solution pooling or persistent state in PHP, it hasn't got an application state like Java, it more or less follows the stateless protocol that is HTTP. What you can do is:
PHP is hardly ever the bottleneck. Our servers handle hundreds of requests per second at peak moments. And those are not tiny requests too. It seems illogical, but PHP is actually very fast. And you can use APC cache to cache precompiled PHP files to make it even faster. Then, you can use MemCache to store data, so any query results and data like that can be cached easily without relying on the suboptimal query cache of MySQL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With