Re: Keeping an Array in Memory
From: Amir Khawaja (amir_at_gorebels.net)
Date: 06/18/04
- Next message: lawrence: "performance hit with OOP?"
- Previous message: lawrence: "performance hit with OOP?"
- In reply to: Andrew: "Keeping an Array in Memory"
- Next in thread: Andrew: "Re: Keeping an Array in Memory"
- Reply: Andrew: "Re: Keeping an Array in Memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 17 Jun 2004 19:39:50 -0700
Andrew wrote:
> I'm afraid I don't know PHP well enough
> to figure this out.
>
> What I would like is to keep an array in
> memory so that it doesn't have to be
> reloaded each time a .php script is run.
>
> Is this possible?
>
> In Java, I could load the array from a file
> in the init() method of a servlet and it would
> stay in memory until the server is shutdown
> or restarted, etc.
>
> Thanks,
>
> Andrew
>
>
Andrew,
Unlike in a Java servlet environment, arrays in PHP are not kept in
memory. All objects created by your script are destroyed at the end of
execution. So, once your script is done loading the page, all data
stored in memory is marked for garbage collection. You will have to
store your data structures (I am assuming you want to save persistent
data) in a database, flat file, or any other location that is to your
liking.
Amir.
--
Rules are written for those who lack the ability to truly reason, But for
those who can, the rules become nothing more than guidelines, And live
their lives governed not by rules but by reason.
- James McGuigan
- Next message: lawrence: "performance hit with OOP?"
- Previous message: lawrence: "performance hit with OOP?"
- In reply to: Andrew: "Keeping an Array in Memory"
- Next in thread: Andrew: "Re: Keeping an Array in Memory"
- Reply: Andrew: "Re: Keeping an Array in Memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|