Application data persistence in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sausheong
Forum Newbie
Posts: 3
Joined: Mon Mar 24, 2003 12:24 pm

Application data persistence in PHP

Post by sausheong »

Hi,

Hope this question doesn't sound too dumb -- I'm a JSP programmer who's really new in PHP and I'm looking to do something that I'm able to do in JSP/Servlets but can't seem to find the equivalent in PHP. I want to be able to load up data into memory and persist it throughout the lifecycle of the PHP application. I want to do this so in order to keep certain data in memory that I usually will load only once and will change very infrequently.

I've been looking into global variables but that doesn't look too promising. Am I missing something important here? I'm really new in PHP.

Thanks.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

serialize() might be what you're looking for - see manual
sausheong
Forum Newbie
Posts: 3
Joined: Mon Mar 24, 2003 12:24 pm

Post by sausheong »

Actually what I wanted to do is to read some XML up into memory and access it whenever I need it. In Java I would use a Singleton and retrieve the instance that is stored in memory everytime I need it. I don't want to read the same XML file for every user that logs in because file access is rather expensive. How can I do the same in PHP?

Thanks for your help!
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

never used it, but here's a link to the shared memory section of the php site http://www.php.net/manual/en/ref.shmop.php
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

implementing a GoF Singleton pattern in php might be difficult since to my knowledge there is not much kept in memory between two requests; the lifecycle of php is different from jsp's.
Post Reply