[UPHPU] Class and Object Storage

Justin Giboney giboney at giboneydesigns.com
Sun Feb 17 21:36:43 MST 2008


Alvaro Carrasco wrote:
> Since PHP is stateless by design, you cannot maintain an object alive 
> past one request. In PHP, everything is created and then destroyed on 
> every request. The only thing you can do is save the contents of the 
> object (possibly by serializing it) and re-create it on the next 
> request. Have you profiled the application? Instantiating a couple of 
> objects is not generally an expensive operation (compared to other 
> things), so is it really such a big problem to have object 
> instantiated on every request.
>
> If you really, REALLY want to keep an instantiated object across 
> requests, do a google search for "php bananas" or "php script running 
> machine". I don't know if it's usable though.
>
> Alvaro
I think that I can do it with memcached, but as said before that is a 
lot more overhead. It isn't the processing time to create objects that 
bothers me, it is the additional creation of an object that should not 
ever have two objects of that type at the same time in existence ever.

Thanks,

Justin Giboney


More information about the UPHPU mailing list