|
Posted by C. (http://symcbean.blogspot.com/) on 12/03/07 13:23
On 2 Dec, 14:56, Viator <varioustr...@yahoo.com> wrote:
> Hi folks,
>
> I have a basic question. When I do object-oriented programming
> using C++ or Java, all my objects reside in RAM. I do not have
> to think about storing and retrieving them, because they are
> in RAM and that space has been allocated for them and
> the program is continually running, so neither program nor
> objects are going to disappear.
>
As the other correspondents have pointed out - that is the case with
PHP as long as the current thread is being executed. It is also true
of Java and C++ when invoked as a new execution thread via CGI - most
commonly for Java complex applications are implemented via containers
where a significant part of the process continues after the request
thread is completed.
You shouldn't have to think too much about storing/retrieving data
with PHP - read up on sessions. This of course does not address the
class definition part of an object - you can manually reference the
definitions within your code but its a lot simpler to adopt a
consistent approach to where you keep these and use the autoload
functionality (loading of a definition of a class instantiated in the
session is deferred).
> however
> it takes time to get them out, and to store them back into it.
>
Most Web based Java applications have a similar problem/overhead
because the session has to replicate across the nodes - IME this is
much more painful than PHP's session handling which is intrinsically
at the storage layer.
(I also have a pet peeve about ORM - I think its a bad idea)
> So the question is, I think, appropriate. Since PHP has
> (AFAIK) no object storage other than a database, is
> OOP in PHP really appropriate?
>
You don't have to use a database. By default sessions are stored on
the filesystem but you can put them anywhere you can access via PHP -
a database or shared memory are obvious candidates. The filesystem can
easily be in RAM if you like.
Why do you think it's not fast enough?
C.
Navigation:
[Reply to this message]
|