wepnop Posted June 17, 2011 Share Posted June 17, 2011 Exist in php a way to load or execute a thing only when you start the server and anything more? Because using sessions for example, you can check if exist, but thas too bugy and also exist a sesion for each user, so if i want a permament array of errors, for example, for each conection it will be created that array and some other things, and i want to have all the errors in one... Quote Link to comment https://forums.phpfreaks.com/topic/239678-permanent-data-in-php/ Share on other sites More sharing options...
Alex Posted June 17, 2011 Share Posted June 17, 2011 You can just store the errors in a log file, and load the errors into an array using file when you need. Quote Link to comment https://forums.phpfreaks.com/topic/239678-permanent-data-in-php/#findComment-1231176 Share on other sites More sharing options...
wepnop Posted June 17, 2011 Author Share Posted June 17, 2011 Thats a way but... my problem is also that i was looking to instantiate some complex object that can have lots of data only a time in the server, and be accesed permantley, so you dont waste resources recreating that object. Quote Link to comment https://forums.phpfreaks.com/topic/239678-permanent-data-in-php/#findComment-1231178 Share on other sites More sharing options...
xyph Posted June 17, 2011 Share Posted June 17, 2011 So you want to store an object permanently in memory? I don't think this is possible. From what I've read, even trying to keep a class in a static state through multiple page requests (via serialize+session, or other means) can cause serious debugging headaches, and is quite slow. Quote Link to comment https://forums.phpfreaks.com/topic/239678-permanent-data-in-php/#findComment-1231232 Share on other sites More sharing options...
RussellReal Posted June 17, 2011 Share Posted June 17, 2011 shared memory blocks should be pretty sufficient, I've used them a while back they were pretty nifty, but they're pretty hard to work with.. and could be simplified by simply piping php files together.. (popen) but for what YOU want, you'd probably want shared memory blocks, but honestly you're going to have to establish a lock to access data in the shared memory blocks, and also you're blocking data away from the rest of your server, for things you could simply use a text file for.. Your best bet in any event (take it from us, here at phpfreaks) a text file is one of the better options for simple text storage, databases for indexed text storage, I mean, there isobviously a good reason these were created.. and you only sacrifice a fraction of a second to establish any resources associated with file handling, database handling is similarly costless, but text files are very fast. Quote Link to comment https://forums.phpfreaks.com/topic/239678-permanent-data-in-php/#findComment-1231241 Share on other sites More sharing options...
xyph Posted June 17, 2011 Share Posted June 17, 2011 This is worth looking at as well http://www.php.net/manual/en/memcached.construct.php Quote Link to comment https://forums.phpfreaks.com/topic/239678-permanent-data-in-php/#findComment-1231261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.